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

SSR Support #61

Open
MoritzKn opened this issue Aug 12, 2022 · 0 comments
Open

SSR Support #61

MoritzKn opened this issue Aug 12, 2022 · 0 comments

Comments

@MoritzKn
Copy link

MoritzKn commented Aug 12, 2022

Is your feature request related to a problem? Please describe.
Currently, when using withPasswordProtect() the initial render will always be "return null".

https://github.com/storyofams/next-password-protect/blob/93c7ae7ead3a1322a642d02ed127fb0c85689207/src/hoc/withPasswordProtect.tsx#L53-L55

Only after the API call, the App is rendered. No matter if you are already logged in or not. This means when you are working with SSR/pages using getServerSideProps(), you can't verify that the HTML response is correct and that hydration will work in production.

Describe the solution you'd like
In theory, it should be possible to check the cookie and verify the session inside getServerSideProps().
Maybe an API could be added to perform the check in getServerSideProps() and pass the value of isAuthenticated to the ProtectedApp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant