-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Session is not renewed on client side right after SSR state changes #2129
Comments
If I understood correctly, this is a known issue (#596). Now, my circumstances are different because I am not using SSR, but I am leaving this here for discussion and possibly help you guide towards a direction: I also ran into this issue and got around it by using the approach mentioned here as inspiration.
I made a custom HOC for protecting the pages which uses the above hook:
And then I am protecting the pages required with the above HOC.
|
I think the best solution is to trigger the token refresh from client-side, as it's usually the client that will trigger an API call. Then deduplication of these requests would make sure that the same refresh_token isn't used multiple times. |
I just find it a bit bad practice. |
@mahieyin-rahmun This is only a way out for client side. The problem is the state between client side and server side. Not being able to renew client side state after server side rendering, is giving problems. |
I have the same issue with credential provider. to address the concurrency issue, i implemented a simple rotation solution that will keep the old refresh token valid for a few seconds and return the newly generated token on concurrent requests. every thing works fine even on concurrent rotation requests. but when the user navigate back and forth through the browser history the next-auth will send the old token even it has just received a new token (multiple times concurrently). |
Hi all, let's continue the discussion here, I just added our latest update: #3941 (comment) I'm closing this issue. |
Description 🐜
The problem is described here: #2123 (comment)
Seems like when changing the session at server side, the client will still use the old session states.
This leads to false informations at the client side.
How to reproduce ☕️
https://codesandbox.io/s/4gokt?file=/pages/_app.tsx
Changes is at
[...nextauth]
,_app
andclient
._app has getinitialprops, which uses the getSession method.
It will at the server side and client side use the same state, but i expect the client side to use new the new state.
Environment 🖥
The text was updated successfully, but these errors were encountered: