Skip to content

Commit

Permalink
fix: remove useless call and correct fetch body (#14)
Browse files Browse the repository at this point in the history
- make ` nuxt._route.matched[0].path` fallback to `/` (when using only
app.vue)
- remove useless fetch call to unexisting endpoint
  • Loading branch information
huang-julien authored May 7, 2023
1 parent caa58f6 commit 12ae403
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/runtime/devtools/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default function initServer (nuxt: Nuxt) {
routes: routesCount
})
}
return 'ok'
})
})
}
2 changes: 1 addition & 1 deletion src/runtime/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineNuxtPlugin((nuxt) => {
$fetch('/__hydration_ping', {
method: 'POST',
body: {
route: nuxt._route.matched[0].path
route: nuxt._route.matched[0]?.path ?? '/'
}
})
}
Expand Down
12 changes: 1 addition & 11 deletions src/runtime/view/TheContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,14 @@
<script setup lang="ts">
// @ts-ignore tsconfig
import { watch, ref } from 'vue'
import { useRoute, useState } from '#imports'
import { useState } from '#imports'
const route = useRoute()
const hydrationFailed = useState('hydration-failed', () => false)
const state = ref(false)
watch(hydrationFailed, () => {
if (hydrationFailed.value) {
state.value = true
// @ts-ignore tsconfig
$fetch('/_hydration_state', {
method: 'post',
body: {
route: route.fullPath,
hydrationFailed: true
}
})
}
})
</script>
Expand Down

0 comments on commit 12ae403

Please sign in to comment.