Skip to content
Back

Nuxt Middleware Support

  • 0
  • Web
OddBit
15 Oct, 2025, 08:40

So I'm trying to protect some routes so that the user is redirected back to the login screen should they not have an active session.

However, I'm stuck in a loop where by a user can log in but if they refresh the page they are sent back to the login screen.

I have created a composable for the authentication but it fails to get the user session on refresh saying i'm not permitted to use account.get() (which i understand that a user has to be logged in to use) but the user is logged in and its throwing the error.

TL;DR
- Developer is attempting to implement Nuxt Middleware to protect routes and redirect users without active sessions to login screen. - Encountering a loop issue where upon login, refreshing the page sends the user back to login screen. - Created a composable for authentication but fails to retrieve user session on refresh due to unauthorized account.get() operation. **Solution:** Check the composable logic to ensure proper authentication state is maintained; verify the handling of user sessions and permission for account operations. Review middleware setup to prevent loop redirection issue on page refresh.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more