-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Closed
Labels
HeadersRelated to the async headers() function.Related to the async headers() function.MiddlewareRelated to Next.js Middleware.Related to Next.js Middleware.locked
Description
Link to the code that reproduces this issue
https://github.com/sommeeeer/next-middleware-headerslist-issue
To Reproduce
pnpm build && pnpm startcurl http://localhost:3000/issue- go to http://localhost:3000/issue-page
Current vs. Expected behavior
I have taken the example code from https://nextjs.org/docs/app/building-your-application/routing/middleware#setting-headers and put it in my middleware.ts. This breaks headers() in any route:
You will get an error saying:
I expect headers()to work, even though I have modified the request headers in middleware.ts
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #47~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Oct 2 16:16:55 UTC 2
Available memory (MB): 14800
Available CPU cores: 16
Binaries:
Node: 20.18.0
npm: 11.1.0
Yarn: N/A
pnpm: 9.15.4
Relevant Packages:
next: 15.2.4 // Latest available version is detected (15.2.4).
eslint-config-next: 15.2.4
react: 19.1.0
react-dom: 19.1.0
typescript: 5.8.2
Next.js Config:
output: N/AWhich area(s) are affected? (Select all that apply)
Headers, Middleware
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local)
Additional context
No response
Metadata
Metadata
Assignees
Labels
HeadersRelated to the async headers() function.Related to the async headers() function.MiddlewareRelated to Next.js Middleware.Related to Next.js Middleware.locked
