next.js icon indicating copy to clipboard operation
next.js copied to clipboard

fix: set x-deployment-id to every middleware prefetch request

Open abvthecity opened this issue 4 months ago • 1 comments

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.

abvthecity avatar Oct 12 '24 14:10 abvthecity