You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
Environment
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 tofalse
and we could override the error behavior by setting$auth.onError
handler. I couldn't find a similar config in this module.Logs
The text was updated successfully, but these errors were encountered: