-
Notifications
You must be signed in to change notification settings - Fork 81
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
Strapi Login logout after page refresh #138
Comments
Hey @tobias-srf, The user might be getting logged out when the Otherwise, could you provide a reproduction link? |
I have the same problem and i am getting 403 with |
Hi @benjamincanac I currently don't have any reproduction link, just running localhost. However, I am also using nuxt-i18n and I have noticed that it creates more than one cookie for different urls. Could this be the issue? When is the |
@tobias-srf Have you tried forcing the cookie path? strapi: {
expires: '30d',
cookie: {
path: '/'
}
} |
@kainio You might need to set authorizations for |
Ok that is much better, only one cooke now. Login problem is, however, still prevailing, but now the cookie is deleted... |
@benjamincanac my bad, i created an new role but forgot to add 'User.me'. thanks |
@benjamincanac I am doing SSR and following code will tell me that I am logged out on a page refresh, so the issue still prevails!
|
Your wrote: I see no such request being sent to any |
@tobias-srf Could you share the code you're using to login your users? |
@benjamincanac nothing spectacular here ...
|
Once you've logged in, your getting disconnected upon refresh? At this moment, don't you see a Also, have you tried not to override the cookie key ( |
I log in and get a perfect redirect to my profile page (as in login code above). Username is shown etc ... |
@benjamincanac I think I found the issue. I am using docker and run nuxt and strapi on the same instance. I have a port forwarding set aside for either application. If I tell nuxt to use the port forwarded port for strapi I get the issue. If I use the internal url via nuxt 127.0.0.1:1337 I get the /user/me GET call and everything is fine and the user stays logged in! So it looks like it is a partial network issue .... |
Glad you found the source of your problem, unfortunately I might not be able to help you on this. Feel free to open a pull request on the documentation explaining this. |
I guess the issue is that the strapi module does not respect the |
@tobias-srf I fixed this issue by completely clearing the application cache (I was using Google Chrome) and modifying my options object to the following: strapi: {
url: 'https://strapi.mydomain.net',
key: 'authToken',
expires: '7d',
cookie: {
sameSite: true,
path: '/'
}
} Upon inspecting my Network tab when it would redirect me to /login and display I wasn't logged in, I found some duplicate cookies which I'm assuming is what was causing the issue. I hope this helps! |
I applied the same but it still doesn't work for me. @pixelscript-io does the same issue still happen with you after anytime soon ? |
Thank you! For me this worked. Setting an url to the strapi module fixed the issue. While local development the call to strapi was over localhost. Changing strapi's url in nuxt config to http://127.0.0.1:1337 fixed it.
|
I am having trouble keeping $strapi.user persistent. I can login fine and cookies and local storage is also set, but upon a page request the user gets logged out straight away.
Is this expected behaviour?
I have tried following:
To keep the session from expiring ...
The text was updated successfully, but these errors were encountered: