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
asPath in getInitialProps ignores query params in dev mode #21267
Comments
I can reproduce this issue. I think the reason that this issue happens in only dev is next.js/packages/next/build/webpack-config.ts Line 216 in 699a7ae
Since a rewirte flag is on in dev, it goes through here where a query is not applied to the path
I am not sure why a rewrite flag is always true in dev. |
I'm getting a similar issue. For me I have rewrites set up and the |
Thanks @kaykdm. |
Hi, this has been updated in the latest version of Next.js |
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. |
What version of Next.js are you using?
10.0.5
What version of Node.js are you using?
12.18.3
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
npm run dev
Describe the Bug
When using dev mode, the value of
asPath
ingetInitialProps
is correct only when rendered by the server. When rendered by the browser, only the path is included, and the query portion is ignored.In prod (npm start), everything works as expected. This leads me to believe that there is some kind of race condition that surfaces only when the app is slowed down due to being in dev mode.
Expected Behavior
The value of
asPath
should consistently include the query portion both on the server and in the browser, even in dev mode.To Reproduce
/pages/test1.js:
/pages/test2.js:
Upon initial SSR render, navigating to
/test1?foo=bar
will correctly display the entireasPath
. But after clicking "go to /test2?foo=bar," only/test2
is displayed, even though the actual path includes a query string.Note that this happens both when using the
Link
component, as well as withrouter.push
.The text was updated successfully, but these errors were encountered: