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
next/link + client-side redirects #41344
Comments
Hi, this is currently expected, please see an explanation here: #40062 (comment) |
Thank you for taking a look at this and I'm sorry to push on this @balazsorban44 @ijjk. I don’t think this should be closed, this seems unrelated to #40062 (comment). Listed above are two unexpected experiences for our end-users.
Expected behavior for end-users is when a user clicks a link, they are correctly redirected and address bar updates accordingly. If this is implementation is expected, can you provide a proposed solution on how to use next/link in combination with next.config.js redirects/rewrites? |
This is currently expected due to the way middleware resolving works vs pure client side routing. We want to avoid shipping an entire manifest with all redirects to the client so pure client side routing does not apply redirects during a transition but middleware can since it does a request to the server and can resolve the rewrites without a client manifest. We can investigating handling for this in the future to avoid this without middleware as well. Note: rewrites are resolved on pure client-side routing because there should inherently be less rewrites than redirects so aren't as expensive to pass to the client. |
@ijjk, once again, thank you for taking the time to consider this issue. I think the second item in this issue is being overlooked or ignored. When middleware is used, the redirect is acting like a rewrite. The address bar is not updating correctly. Is this expected? See this video or pull my repo to reproduce. Screen.Recording.2022-10-11.at.3.54.32.PM.mov |
Yeah this is also expected for internal redirects (start with |
Ref: #41344 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
Ref: vercel#41344 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
What browser are you using? (if relevant)
Chrome Version 106.0.5249.103 (Official Build) (x86_64)
How are you deploying your application? (if relevant)
No response
Describe the Bug
I'm experiencing unexpected behavior when using next.config.js redirects.
Without middleware:
Redirects added into next.config.js are not followed when using next/link for client-side routing. Only refreshing the page will redirect as expected.
Screen.Recording.2022-10-11.at.3.32.48.PM.mov
With middleware:
Redirects added into next.config.js will update the rendered page content, but the URL in the address bar does not update. The redirect is acting like a rewrite.
Screen.Recording.2022-10-11.at.3.54.32.PM.mov
Related discussion:
#40062
Expected Behavior
With or without middleware, I expect routing to follow next.config.js redirect rules.
Link to reproduction
https://github.com/dpogni/next-redirect-test
To Reproduce
The text was updated successfully, but these errors were encountered: