Nuxt · Routing
NUXT0048Use middleware to/from arguments instead of useRoute
Flags useRoute in middleware in Nuxt routing code before it leaks into runtime behavior.
vite-doctor/nuxtroutingerrorSuggestion
Why it happens
Navigation helpers only work correctly in the runtime they were designed for. Returning the navigation result keeps redirects and aborts observable to Nuxt.
Fix
Remove useRoute in middleware, or move it to the Nuxt runtime/API that owns that behavior.
Example
Use middleware arguments
Before
export default defineNuxtRouteMiddleware(() => {
const route = useRoute()
if (!route.meta.auth) return
})
After
export default defineNuxtRouteMiddleware((to) => {
if (!to.meta.auth) return
})
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm nuxt doctor --rules nuxt/routing/no-useroute-in-middleware