next.js
next.js copied to clipboard
Next 13: setting headers in middleware causes full page reload between navigations
Verify canary release
- [X] I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64
Binaries:
Node: 16.13.1
npm: 8.19.1
Yarn: 1.22.17
pnpm: 7.12.0
Relevant packages:
next: 13.0.0
eslint-config-next: 13.0.0
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
Chrome
How are you deploying your application? (if relevant)
Version 105.0.5195.125 (Official Build) (x86_64)
Describe the Bug
#41380 introduced a way to override headers from middleware.
Using this functionality causes next/link
to trigger full-page reload between navigations.
This is only an issue for next dev
. There is no bug when it's deployed on Vercel.
Expected Behavior
There should not be a full-page reload when next/link
is used.
Link to reproduction
https://github.com/colinclerk/appdir-middleware-bug
To Reproduce
Clone the repo and start the dev server, then click the links between "Index" and "Page 2" - you should see full-page reloads
If helpful, here's the deployed version that doesn't exhibit the issue: https://appdir-middleware-bug.vercel.app/
Same happening to me. Following.