Can't input url manually
after i installed nuxtjs/supabase when i manually enter
http://localhost:3000/anime/45816?type=video it will redirect me to http://localhost:3000/?type=video to changed the path
here is my auth.js middenware
when i use route.push it worked prefectly
here is my nuxt.confit.js
2 Replies
Hi @Asher. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on your description and the provided middleware, the issue is likely related to how the Supabase Nuxt module handles redirects for unauthenticated users. Even though you have set
Your middleware is correct, but the Supabase Nuxt module may still be enforcing redirects unless fully disabled. Ensure your login page exists and that no other middleware is interfering. If the problem persists, it may be a module bug or an undocumented behavior Stack Overflow: Nuxt.js localhost redirects to /login automatically, resulting in 404 error. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
redirect: false in your nuxt.config.js, the Supabase module by default guards routes and may still perform automatic redirects to the login page if a user is not authenticated, as described in the Supabase Nuxt documentation and confirmed by community reports. This can result in unexpected navigation behavior, such as being redirected away from a manually entered URL to the root or login page, especially if the login page does not exist or is misconfigured Stack Overflow: Nuxt.js localhost redirects to /login automatically, resulting in 404 error.
Key points:
- The Supabase Nuxt module can automatically redirect unauthenticated users, even if you try to disable it, unless you fully configure the redirectOptions and ensure your login page exists.
- If you use navigateTo in your middleware, you must always return its result to ensure correct navigation flow Nuxt 3 Docs: navigateTo.
- Using router.push is not recommended in Nuxt middleware; you should use navigateTo instead for proper SSR/client handling Stack Overflow: Redirect to auth screen if no token is available.
What you can do:
1. Double-check that your /auth/login page exists.
2. Make sure your Supabase module config disables all automatic redirects if you want to handle them manually. According to the docs, you can set redirect: false to disable all redirects, but if you still see redirects, check for any other modules or middleware that might be interfering.
3. Your middleware logic is correct for manual authentication checks and redirection. If you want to prevent the "glitchy" redirect, always use return navigateTo(...) and not router.push(...) in middleware.
Example (as you have):
If you are still being redirected to / or another path, it is likely due to the Supabase module's internal logic or another piece of middleware. You may want to check for any other global middleware or module settings that could be causing this behavior.
Summary:Your middleware is correct, but the Supabase Nuxt module may still be enforcing redirects unless fully disabled. Ensure your login page exists and that no other middleware is interfering. If the problem persists, it may be a module bug or an undocumented behavior Stack Overflow: Nuxt.js localhost redirects to /login automatically, resulting in 404 error. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
<@358819659581227011> Kapa.ai is still learning and improving, please let me know how I did by reacting below.