nuxt catch-all pages causes infinite redirection with route middlewares
Environment
Nuxt project info: 14:22:52
- Operating System: Windows_NT
- Node Version: v18.17.1
- Nuxt Version: 3.7.4
- CLI Version: 3.9.0
- Nitro Version: 2.6.3
- Package Manager: [email protected]
- Builder: -
- User Config: modules, devtools, alias, devServer
- Runtime Modules: @hebilicious/[email protected]
- Build Modules: -
Reproduction
https://github.com/m0zz094/authjs-nuxt-bug
Describe the bug
I have a catch all route where, if the page path is equal to "/reserved-area", i want to add the auth middleware, it looks like this is not working right now
Additional context
No response
Logs
[Vue Router warn]: Detected a possibly infinite redirection in a navigation guard when going from "/reserved-area" to "/login". Aborting to avoid a Stack Overflow.
Are you always returning a new location within a navigation guard? That would lead to this error. Only return when redirecting or aborting, that should fix this. This might break in production if not fixed.
[nuxt] Calling `useRoute` within middleware may lead to misleading results. Instead, use the (to, from) arguments passed to the middleware to access the new and old routes.
Removing session
That's an interesting bug that appears to be Nuxt related. As a workaround, could you use a separated page for your reserved-area instead?
Hi @Hebilicious, I could try this but ideally I'm creating private pages from a headless CMS so there could be different slugs, I'll open an issue in Nuxt