Rewrites not working on client-side navigation in 12.2+
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Binaries:
Node: 14.20.0
npm: 6.14.17
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.0.1-canary.0
react: 18.2.0
react-dom: 18.2.0
Describe the Bug
When using version 12.2
or higher, rewrites don’t work on client-side navigation anymore. It does work when visiting a url directly / refreshing the page. Initially reported in https://github.com/vercel/next.js/issues/38338.
Expected Behavior
Client-side navigations work the same as server-side page loads.
Link to reproduction
https://github.com/luukdv/next-bug
To Reproduce
- Clone https://github.com/luukdv/next-bug
- Run
npm i && npm start
- Open http://localhost:3000
- Click “Visit this link”
- Click “Refresh the page”
Issue Analytics
- State:
- Created a year ago
- Reactions:8
- Comments:7
Top Results From Across the Web
Rewrites not working in dev server client side navigation in ...
This worked perfectly in Next.js through 12.1 but now when I am testing out 12.2, client-side (SPA) navigation in the dev server is...
Read more >Rewrites - next.config.js
Rewrites allow you to map an incoming request path to a different destination path. Rewrites act as a URL proxy and mask the...
Read more >Next.js 12.2 Overview: Middleware, Layouts, and more
Next.js 12.2 introduces stable Middleware and On-Demand ISR, experimental Edge SSR and API Routes, and more.0:00 Intro1:50 Agenda2:30 ...
Read more >Using Sessions and Session Persistence - Oracle Help Center
The extended session ID format will be part of the URL if URL rewriting is ... If you do not allocate sufficient heap...
Read more >JavaScript Tutorial: The Basics
JavaScript is the most widely used client-side programming language ... Run the script by loading the HTML file into a JavaScript-capable ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@luukdv Having the same issue (maybe related to #39638 and #39837) I found that replacing the trailing slash of the
source
with{/}?
does fix the rewrites on client-side navigation.I do not know if this is a bug or the documentation should be updated:
For the home page we used
/{/}?
, which worked for us @luukdv. But not sure if that is actually a good idea.