-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
fix: authState getting wiped on page reload on static websites #785
base: main
Are you sure you want to change the base?
fix: authState getting wiped on page reload on static websites #785
Conversation
set and reload data, rawToken from cookie fix lint fix typecheck
Hello @zoey-kaiser, Thanks ! |
Hi @Geekimo 👋 I would like to get a review by @phoenix-ru in before merging this PR 😊 |
@zoey-kaiser Thanks for your reply |
Any news on this fix or can we help? I use a local provider and having auth work with ssg would be highly appreciated :-) |
Hello @zoey-kaiser and @phoenix-ru, Kind regards. |
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally approved 🥳
Hi @Vijayabhaskar96 👋 I wanted to push this PR into the next release, but sadly the authjs tests are failing. We will finalize the PRs for the release tomorrow. For the case that we are not able to include it yet, you can directly install your PR as an npm package using:
|
Hello @zoey-kaiser, |
Is there a specific reason why this wasn't included in the 0.9.4 release? |
Previous PR: #712
🔗 Linked issue
#551
This issue occurs because
data
(data fromgetSession()
) is not stored in the browser, which is not a problem in SSR with server because the server takes care of it, but on a statically generated website, thisdata
is lost along withrawToken
even if the token is stored in the browser cookies if you refresh the webpage.❓ Type of change
📚 Description
This PR stores the retrieved data from
getSession()
and stores it in the browser cookieauth:sessionCookie
and reloads thedata
andrawToken
back on the client side if they'reundefined
.This PR fixes the data issue, but you still need to set the
prerender:false
for middleware protected routes in routeRules so that client-side middleware is forced to run and load the states.📝 Checklist