Skip to content
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 #712

Closed
wants to merge 5 commits into from

Conversation

Vijayabhaskar96
Copy link
Contributor

🔗 Linked issue

#551
This issue occurs because data (data from getSession()) 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, this data is lost along with rawToken even if the token is stored in the browser cookies if you refresh the webpage.

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This PR stores the retrieved data from getSession() and stores it in the browser cookie auth:sessionCookie and reloads the data and rawToken back on the client side if they're undefined.
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

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.

@zoey-kaiser zoey-kaiser added the bug A bug that needs to be resolved label May 9, 2024
@zoey-kaiser
Copy link
Member

Hi @Vijayabhaskar96 👋

The tests are sadly failing and this PR has some merge conflicts. When you have a chance to address these, feel free to ping me again and I will review the changes ❤️

@Vijayabhaskar96
Copy link
Contributor Author

I fixed merge conflicts and I accidentally created a new pull request. follow it #785

I couldn't test it locally because of this new bug #782

@zoey-kaiser
Copy link
Member

@Vijayabhaskar96, so this PR is now outdated right? I would then close this PR just so we focus on the correct one 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug that needs to be resolved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants