Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User gets logged out when the user endpoint encounters any kind of error (Not just 401) #998

Open
sadeghi-aa opened this issue Feb 9, 2025 · 0 comments
Labels
enhancement An improvement that needs to be added provider-local An issue with the local provider

Comments

@sadeghi-aa
Copy link

sadeghi-aa commented Feb 9, 2025

Environment

  • Operating System: Darwin
  • Node Version: v20.18.1
  • Nuxt Version: 3.15.4
  • CLI Version: 3.21.1
  • Nitro Version: 2.10.4
  • Package Manager: [email protected]
  • Builder: -
  • User Config: compatibilityDate, devtools, css, app, modules, postcss, vite, runtimeConfig, auth
  • Runtime Modules: @pinia/[email protected], @nuxt/[email protected], @sidebase/[email protected]
  • Build Modules: -

Reproduction

Mock the response of the user endpoint so that it doesn't get a 200 response; anything other than a 401 error would be fine.

Describe the bug

When the API call for the user endpoint gets an error, the user gets logged out. This is an unwanted behavior for our use case. We only want to log out the user when an API call gets a 401 error. Other cases could be temporary network or server issues and logging out the user is an extreme reaction because the issue is very likely to be resolved with a refresh (assuming the JWT token is still valid).

Additional context

@nuxtjs/auth-next module had a config called resetOnError which could be set to false and we could override the error behavior by setting $auth.onError handler. I couldn't find a similar config in this module.

Logs

This is an example error log of the scenario I described.
Our website could only be accessed via a VPN and if you open the website without that VPN, you get logged out.
This would be annoying for the users.

ERROR  Session: unable to extract session, [GET] "https://some.domain.com/api/user/": 403 Forbidden
@sadeghi-aa sadeghi-aa added bug A bug that needs to be resolved pending An issue waiting for triage labels Feb 9, 2025
@sadeghi-aa sadeghi-aa changed the title User gets logged out when the user endpoint gets encounters any kind of error User gets logged out when the user endpoint encounters any kind of error (Not just 401) Feb 9, 2025
@phoenix-ru phoenix-ru added enhancement An improvement that needs to be added provider-local An issue with the local provider and removed bug A bug that needs to be resolved pending An issue waiting for triage labels Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement that needs to be added provider-local An issue with the local provider
Projects
None yet
Development

No branches or pull requests

2 participants