next.js
next.js copied to clipboard
fix: set x-deployment-id to every middleware prefetch request
What?
x-deployment-id
is missing on prefetch requests
Why?
To handle version skew on the pages router. When version skew is turned on, x-deployment-id
should be used on prefetch otherwise the server will return 404. But with middleware enabled, the 404 does not appear to hard-refresh the page.
How?
The downside is next.js seems to be relying on the 404 to perform a hard navigation and auto-refresh the client. But that doesn't appear to happen when middleware is in use, which is causing the client to navigate to 404 whenever we deploy a new version of the site to vercel.