Replies: 6 comments 3 replies
-
Would love some input on this issue as well, we use rewrites to not expose our internal apis to the internet and this feature just leaks the internal URI for those APIs which is not great. |
Beta Was this translation helpful? Give feedback.
-
Never understand the mind behind this ideas. why everything is locked and limited in Next.js! you can't remove headers. you can't access the request object in page components. what back-end framework is this! |
Beta Was this translation helpful? Give feedback.
-
I've been unable to find a related issue (open or closed) for this as well. Will need help. |
Beta Was this translation helpful? Give feedback.
-
Took a look in the source code, i "think" the header is added here next.js/packages/next/src/server/web/spec-extension/response.ts Lines 135 to 144 in 6bebacb doesn't look like there is a way in NextJS to disable. The one solution I found, if you set that exact header where the request is rewrote to, the nextJS header is overwritten. the client appears to get whatever value you set. For example. response.headers["X-Middleware-Rewrite"] = "--" |
Beta Was this translation helpful? Give feedback.
-
+1 for the option to hide When manually overwriting header, it becomes always pending connection middleware(req: NextRequest) {
const response = NextResponse.rewrite(url)
response.headers.set('X-Middleware-Rewrite', '')
return response
} |
Beta Was this translation helpful? Give feedback.
-
Just ran into this issue, have any of you found any work-arounds? |
Beta Was this translation helpful? Give feedback.
-
Summary
Hi,
We´re using NextResponse.rewrite in our middleware for passing certain requests to an internal api. The api in question has safety measurements set up, and is only reachable by whitelisted networks, but we would still prefer it if the actual internal url was not displayed to external users. However, when performing such a rewrite, the http header "x-middleware-rewrite" is set on the response and contains the internal url. Is there any way to remove this header from the response?
Best regards,
Dan
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions