Add support for middleware rewrite proxy headers #33200
Replies: 7 comments
-
It appears this would fix the problem raised in this discussion #31188 |
Beta Was this translation helpful? Give feedback.
-
any solution? Are we supporting nextjs middleware as http-proxy? |
Beta Was this translation helpful? Give feedback.
-
Gonna have to vouch for this one as well. |
Beta Was this translation helpful? Give feedback.
-
I've also run into this limitation. I've raised a PR: #35093 |
Beta Was this translation helpful? Give feedback.
-
Would be great if this was supported. I'd also like to proxy an authorization header to the destination without exposing it to the client. |
Beta Was this translation helpful? Give feedback.
-
Any update on this? |
Beta Was this translation helpful? Give feedback.
-
Any updates? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the feature you'd like to request
I would like to be able to specify headers to be sent by the proxy that is running behind the
NextResponse.rewrite
middleware response.I understand it's possible to set headers in the
NextResponse.rewrite
response, but these headers are sent to the user visiting the next.js page, what I would like is to set headers that the destination server will receive.Upon digging into the next.js internals, I understand we'd need to provide such headers in the
Proxy
instance withinproxyRequest
inside/packages/next/server/base-server.ts
Describe the solution you'd like
I would like to be able to, perhaps, provide a config object as second parameter of
NextResponse.rewrite
which could accept something likeforwardHeaders
that accepts a Headers object and this would then be merged with the headers that the proxy may already need to send.Describe alternatives you've considered
Currently, my alternative solution is preform this rewrite using nginx and provide the headers there. If these headers can be forwarded within nextjs, I believe this feature will be even more powerful.
Beta Was this translation helpful? Give feedback.
All reactions