Closed rizen closed 3 months ago
I have learned a few things:
Turns out if you create a middleware that just fetches anything at all, that will also work around this problem.
export default defineNuxtRouteMiddleware(async () => {
await $fetch(`/api/v1/test`);
});
This bug is caused by something in useRequestEvent()
inside of Nuxt, which is used in useRest()
in ving, which in turn calls useRequestHeader()
which calls useRequestEvent()
.
The first call to useVingKind() .all() is fine in SSR, but a secondary call will crash unless it has a middleware that fetches something with $fetch()
like the all-workaround
middleware I have added to ving.
Alternatively, don't call all, and instead just run the code you want to run in the page rather than inside the useVingKind() composable.
I hate that we have to have this work around, but I can't figure out any other way to solve this problem. Hopefully whatever is broken inside of Nuxt will be fixed in the future.