Middleware: Response headers gets set on Request aswell
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.5k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://github.com/sommeeeer/opennext-middleware-request-headers-issue
To Reproduce
pnpm build && pnpm startcurl http://localhost:3000/test- Visit http://localhost:3000/issue-page and http://localhost:3000/issue-action
Current vs. Expected behavior
When you set response headers in middleware.ts I expect it not to be on both the request headers and response headers in any route. Can confirm this is an issue on 15.x.x, and on latest 14.
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/A
Which area(s) are affected? (Select all that apply)
Middleware, Headers
Which stage(s) are affected? (Select all that apply)
next start (local), next dev (local)
Additional context
I tested with standalone build too. Same problem there.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction repository and run pnpm build && pnpm start, then request /test and visit /issue-page and /issue-action. Inspect middleware.ts and the middleware request/response handling involved in those routes; done means response headers set by middleware no longer appear in request headers across the reported local stages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nextjs, react
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100