-
-
Notifications
You must be signed in to change notification settings - Fork 162
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
After logging in I am redirected to login page when refreshing the page #754
Comments
I have the same issue with refresh. Super super frustrating. |
have you tried to add x-forwarded-proto: https from your proxy manager? to help debug I also tried to copy the codes in the middleware and use the code in the file to recreate my own global middleware in my Nuxt to see all values and to see where was the problem that's where I found status becomes unauthenticated in the middleware when x-forwarded-proto header has HTTP as the value make sure you have this structure 01.xxxxxx.global.ts as the file name so it can be triggered before anything else + globally |
I have not enabled the globalMiddleware from sidebase-auth settings. I also don't have a reverse proxy, although I do have a server middleware (in nuxt) that redirects http to https. I'm dealing with this in production. Whenever I deploy my app, everything is fine, people log in and stay logged in across refreshs. But after a couple of hours, it's your post happening all over again. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as spam.
This comment was marked as spam.
Hi everyone 👋 I completely understand your frustration with this issue! We had already begun investigating a similar issue in #732 (as mentioned by @mbellamyy) and had pushed some changes in the 0.8.0-alpha.2 release. For housekeeping reasons, I would close this issue for now, please test the new alpha release and add any further comments in #732! |
Environment
Reproduction
Refresh Page after logging in
Describe the bug
Settings for nuxt-auth
I am experiencing a weird behaviour that after logging in if I don't refresh the page everything works fine.
However, once I refresh the page then I can see from browser dev tool the value of
__Host-next-auth.csrf-token
keeps changing then it redirects me to the login page and becomes unauthenticated but it does now keep changing when running in dev modeI found a solution from another post it did help a bit when so when I have following on my page then it remaining authenticated after refreshing the page but still redirects me to login page
Additional context
nuxt-auth versions used 6.3, 7.0, 7.1, 7.2
I have the globalAppMiddleware set to true and I noticed that when
const { status } = useAuth();
is called in middlewarenode_modules/@sidebase/nuxt-auth/dist/runtime/middleware/auth.mjs
status returns unauthenticated then it redirects me to the sign in page but I am already signed in at the point.Reason of the behaviour -- updated on 21May
After some investigations that I found out because I have Nginx reverse proxy.
So Nginx appends the header of "x-forwarded-proto": "HTTP"
if I force that to be "x-forwarded-proto": "HTTPS" then everything works fine again so it was "x-forwarded-proto" causing the issue I was wondering if anyone knows the reason behind this?
Logs
No response
The text was updated successfully, but these errors were encountered: