-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
getInitialProps does not work correctly with back-button #9833
Comments
getInitialProps
does not work correctly with back-button
We need a full demo before we can take a look at this. |
It happens for me using the latest version of safari. I have links that navigate to a new page. When I click back the app crashes because there is no request object. |
It would be more precise to debug if we could see how the user data is passed to your getInitialProps. My initial believe is that this would be caused by how you implement those login session causing them to not send the data (such as not implementing login session storage, etc). Since I could not see how the login session is stored and how the login session is sent, that would be the closest thought. Showing further demo or full demo would be best anyway. |
The issue is:
This issue was on production mode and had different side effects (flickers, crashes, outdated screens). |
Closing as no reproduction provided. |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
I am using Passport.js and Express Sessions which make available a
users
field in the incontext.req
which is passed togetInitialProps
for a Component.As long as I am using the links in the page, everything works fine but as soon as I use the back-button, I am unable to access props, as if they did not exist.
Description
Reaching a page via the back-button causes props to become undefined which are defined when the page is reached via links or reloads.
Code
Here is my
index.js
In this code, the
getInitialProps
runs in the client-side when using back-button, which I confirmed withconsole.log
. I do not think this should be running in client-side, and when it does,context.req
isundefined
.Expected behavior
See GIF below to see the unexpected behavior I am experiencing. I expected the back-button-ed page to look the same as that page accessed directly via URL.
Screen-video
System information
Additional Information
I will look over this #3065 (comment) tomorrow, but I do not think this should work as my problem unrelated to Links and their
href
andas
.I am just getting started in using Next.js so please help me find a link if a solution to it exists!
The text was updated successfully, but these errors were encountered: