x-middleware-subrequest issue with Edge Runtime #77466
Labels
Headers
Related to the async headers() function.
Middleware
Related to Next.js Middleware.
Runtime
Related to Node.js or Edge Runtime with Next.js.
Link to the code that reproduces this issue
https://github.com/enricoros/repro-nextjs-edge-issue
To Reproduce
Example of running this repro:

Current vs. Expected behavior
As a user of the fetch() API to call api endpoints, I expect it to work from both NodeJS and Edge Runtime requests. However what happens is that outgoing request headers differ without any user input.
The substantial difference from Node to Edge as far as outgoing HTTP (fetch) request is:
node
vsNext.js Middleware
/api/edge
vs absentAs this relates to https://nextjs.org/blog/cve-2025-29927, overzealous providers such as Cloudflare may block the fetch request when x-middleware-subrequest is present, rejecting all API calls from Edge Runtimes.
Provide environment information
Which area(s) are affected? (Select all that apply)
Headers, Middleware, Runtime
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Vercel (Deployed)
Additional context
This relates to https://nextjs.org/blog/cve-2025-29927 and https://developers.cloudflare.com/changelog/2025-03-22-next-js-vulnerability-waf/.
Due to the recent vulnerability some providers such as Cloudflare may block "x-middleware-subrequest".
Despite using the latest version of NextJS, fetch() (nodejs) requests that are made from the Edge runtime (export const runtime="edge", as opposed to ...="nodejs") will contain headers that will trigger the blocking rules.
In this report, we show how calling the Perplexity API (one API behind Cloudflare policies) will result in blockage of requests coming from Edge Runtime fetch() calls, and not from the NodeJS Runtime fetch() calls.
Note that the user does not seem to have control of the headers that get injected by NextJS and so does not have any possibility of fixing the issue.
The text was updated successfully, but these errors were encountered: