mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### What? Follow-up of #56797 While working on this, I noticed that some logic around stripping internal headers was duplicated, so I did some cleanup too. ### Why? In #56797 we set these headers, but it only affected Route Handlers, Middleware is still missing them, which is a regression introduced in #52492 (Related: https://github.com/vercel/next-learn/issues/252) ### How? Move to set these headers up to `base-server.ts` so they are present in Middleware too. > Note: All headers are set with `??=` to respect the original value if set (with other words, only add these headers if they aren't set yet) Closes NEXT- Fixes #52266
15 lines
426 B
TypeScript
15 lines
426 B
TypeScript
import { NextResponse } from 'next/server'
|
|
|
|
export function middleware(req: Request) {
|
|
return NextResponse.next({
|
|
headers: {
|
|
'middleware-x-forwarded-host':
|
|
req.headers.get('x-forwarded-host') ?? 'wrong',
|
|
'middleware-x-forwarded-port':
|
|
req.headers.get('x-forwarded-port') ?? 'wrong',
|
|
'middleware-x-forwarded-proto':
|
|
req.headers.get('x-forwarded-proto') ?? 'wrong',
|
|
},
|
|
})
|
|
}
|