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 is incorrect on Server if you use rewrites and getInitialProps #20370
Comments
Im not sure if this is a duplicate as #17143 seems to be an issue with pages using static optimization / getStaticProps. |
I think same issue was used to happen on
|
Thank you very much @kaykdm |
|
@kaykdm PR just fix |
@nghiepit |
@kaykdm |
@nghiepit You are right. This issue still exists, so I reopened my PR. |
@kaykdm Does your PR have a fix for |
@nghiepit |
Fixes: #20370 > AsPath is incorrect on Server if you use rewrites and getInitialProps. On the server, asPath is the rewritten asPath while on the client asPath ist as given in the request URL. The same issue was used to happen on `getServersideProps`, but it was fixed in this PR (#17121). `getInitialProps` needs same fix except when the target is serverless, which has correct `asPath` value. Additional tests have been added in the `getInitialProps` suite to ensure correct asPath with rewrites.
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. |
Bug report
Describe the bug
AsPath is incorrect on Server if you use rewrites and getInitialProps. On the server, asPath is the rewritten asPath while on the client asPath ist as given in the request URL.
To Reproduce
Start with a new next typescript project. And add:
Next.config.js
/pages/product/[pid].tsx
/s1/product/42
Expected behavior
AsPath on server and client ist
/s1/product/42
System information
Additional Information
If you use getServerSideProps instead of getInitialProps it works as expected. You can test this by replacing
with
The text was updated successfully, but these errors were encountered: