You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I verified that the issue exists in the latest Next.js canary release
Provide environment information
not relevant
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
When using the second argument of router.push('/page', '/displayedUrl'), you will navigate to the page 'page', but the browser shows '/displayedUrl'.
When page has a getServerSideProps handler and this handler results in an error being thrown, this causes the next client to do a full page reload to /displayedUrl instead of /page. This will typically result in a 404 page (since /displayedUrl doesn't really exist), rather than an actual reload of page (which isn't really possible, since it isn't routable at all by visiting a URL.
Expected Behavior
An improved behaviour should detect if the 'browser URL' matches the page (i.e. if the second argument of route.push was used.
If there is no match, a refresh does not make sense and a better default would be to immediately navigate to the error page.
Alternatively make getServerSideProps errors configurable/catchable from the client side.
If you run the server yarn dev and click the button, you will be shown a 404 page like described above.
The text was updated successfully, but these errors were encountered:
ghost
added
the
bug
Issue was opened via the bug report template.
label
Sep 23, 2022
ghost
changed the title
Errors thrown in getServerSideProps result in full page reload which is a problem when using the second argument in router.to
Errors thrown in getServerSideProps result in full page reload which is a problem when using the second argument in router.pushSep 23, 2022
ghost
changed the title
Errors thrown in getServerSideProps result in full page reload which is a problem when using the second argument in router.push
Errors thrown in getServerSideProps result in full page reload without respecting the second argument in router.pushSep 23, 2022
A workaround that we are currently using involves wrapping all getServerSideProps handlers in try..catch and on catch, manually logging the error and returning a redirect to the error page.
This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.
This issue has been automatically closed due to two years of inactivity. If you’re still experiencing a similar problem or have additional details to share, please open a new issue following our current issue template. Your updated report helps us investigate and address concerns more efficiently. Thank you for your understanding!
Verify canary release
Provide environment information
not relevant
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
When using the second argument of
router.push('/page', '/displayedUrl')
, you will navigate to the page 'page', but the browser shows '/displayedUrl'.When
page
has agetServerSideProps
handler and this handler results in an error being thrown, this causes the next client to do a full page reload to/displayedUrl
instead of/page
. This will typically result in a404
page (since/displayedUrl
doesn't really exist), rather than an actual reload ofpage
(which isn't really possible, since it isn't routable at all by visiting a URL.Expected Behavior
An improved behaviour should detect if the 'browser URL' matches the page (i.e. if the second argument of
route.push
was used.If there is no match, a refresh does not make sense and a better default would be to immediately navigate to the error page.
Alternatively make
getServerSideProps
errors configurable/catchable from the client side.Link to reproduction
https://github.com/TomKlaverAH/nextjs-issue-example
To Reproduce
See changes from commit https://github.com/TomKlaverAH/nextjs-issue-example/commit/a36ca42cb14641c30a2a37e52c915b2e6dcec09a
If you run the server
yarn dev
and click the button, you will be shown a 404 page like described above.The text was updated successfully, but these errors were encountered: