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

Back button for rewritten page broken in last version #25490

Closed
PepijnSenders opened this issue May 26, 2021 · 6 comments · Fixed by #25666
Closed

Back button for rewritten page broken in last version #25490

PepijnSenders opened this issue May 26, 2021 · 6 comments · Fixed by #25666
Labels
bug Issue was opened via the bug report template.

Comments

@PepijnSenders
Copy link
Contributor

What version of Next.js are you using?

10.2.3

What version of Node.js are you using?

14

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

none

Describe the Bug

Pressing the back-button to a rewritten page causes this bug for us in the latest version:

Screen Shot 2021-05-26 at 10 34 29 AM

Seems like shouldResolveHref, which was added in #25112 is now false and the router is not able to resolve the href anymore.

Expected Behavior

Back button to work.

To Reproduce

Have a page that is served through a rewrite, go to another page through a next/link transition (only reproducible on the second transition when the page has not been built yet and you're testing it locally), go back to the previous page with the browser back button will throw this error.

@PepijnSenders PepijnSenders added the bug Issue was opened via the bug report template. label May 26, 2021
@PepijnSenders
Copy link
Contributor Author

PepijnSenders commented May 26, 2021

Apparently, the issue is a bit more complex (probably why it wasn't caught by the current integration tests), but this only breaks when the page has dynamic params (like: [[...param]].jsx), the rewrite has two params and the page needs export const getServerSideProps as well. You can see this in the integration test that I added here.

@m-bp
Copy link

m-bp commented May 27, 2021

This is happening to me and we don't use getServerSideProps. We do have dynamic routes and use params in the rewrite, but only one.

@ctestamarck
Copy link

ctestamarck commented May 28, 2021

We're experiencing the same issue using a rewrittten route with one dynamic param, along with getStaticPaths and getStaticProps. Tested with v10.2.4-canary.0. All click-based navigation works fine using only href param on Links and router.push. I tried adding the 'as' param to Links but that causes the same error message as above when links are clicked.

@PaulSenon
Copy link

Same here.

The problem appears between v10.2.1-canary.6 and v10.2.1-canary.7.
It might be related to this commit: 5bff9ea

A similar issue has been opened and fixed on v10.2.4-canary.0 (#25285)
but it seems that it does not really fix the issue...

Here is one sample project to reproduce the bug:
https://stackblitz.com/edit/bug-nextjs-router-back-as-path?file=next.config.js

I also forked and updated (with v10.2.4-canary.0) the example from @DaniAkash from the original issue:

In the meantime, you'll have to rollback to 10.2.0 if you're having the issue in production...

Hope it will be fixed soon :/

@PepijnSenders
Copy link
Contributor Author

@ijjk I just tested this with my integration test and it still seems broken. (#25666 (comment)) will see if I can fix it.

@balazsorban44
Copy link
Member

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.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants