vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.49k stars 27.04k forks source link

Can't override headers via middleware #71604

Open mrmckeb opened 1 month ago

mrmckeb commented 1 month ago

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/great-elbakyan-jty6yh

To Reproduce

Start the application and inspect the headers. You'll see that new headers can be added, but existing headers can't be modified.

Current vs. Expected behavior

We should be able to replace or remove headers when rewriting.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Wed Jul 31 20:50:54 PDT 2024; root:xnu-10063.141.1.700.5~1/RELEASE_ARM64_T8122
  Available memory (MB): 24576
  Available CPU cores: 8
Binaries:
  Node: 20.14.0
  npm: 10.7.0
  Yarn: N/A
  pnpm: 9.12.2
Relevant Packages:
  next: 15.0.0 // Latest available version is detected (15.0.0).
  eslint-config-next: N/A
  react: 19.0.0-rc-65a56d0e-20241020
  react-dom: 19.0.0-rc-65a56d0e-20241020
  typescript: 5.6.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Middleware

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

We have a small Next.js app that is designed to proxy between two other apps sharing a single domain.

These apps have headers that we want to modify/remove when their pages are served via the proxy.

We can add headers, but we are not able to modify or remove headers.

amannn commented 1 month ago

Maybe related: https://github.com/vercel/next.js/issues/69000#issuecomment-2416459189