N
Nuxt17mo ago
Mole

Can nuxt 3 middleware be asynchronous?

I am trying the below trivial example with one await and navigateTo, resulting in error:
[nuxt] A composable that requires access to the Nuxt instance was called outside of a plugin, Nuxt hook, Nuxt middleware, or Vue setup function.
[nuxt] A composable that requires access to the Nuxt instance was called outside of a plugin, Nuxt hook, Nuxt middleware, or Vue setup function.
const to = await getRouteTo()
return navigateTo(to)
const to = await getRouteTo()
return navigateTo(to)
1 Reply
Mole
MoleOP17mo ago
Real life example would be auth middleware checking for permissions only after protected route is visited; if permissions are insufficient, redirect user away.
Want results from more Discord servers?
Add your server