About using vercel.json as reverse proxy #7304
Replies: 3 comments
-
@cennne you can set headers but you'd have to hardcode the host and keys {
"headers": [
{
"source": "/specific/:path*",
"headers": [
{
"key": "X-Forwarded-Host",
"value": "host-name"
}
]
}
]
} Or the other hand you can deploy with a import { rewrite } from "@vercel/edge";
export const config = {
matcher: ["/specific-route-seg/:path*", "/other-route-seg/:path*"],
};
export default function middleware(request) {
const url = new URL(request.url);
// rewrite add headers, custom logic, etc
if (url.pathname.startsWith("/specific-route-seg")) {
return rewrite(new URL("/specific-route-seg", request.url));
}
}
|
Beta Was this translation helpful? Give feedback.
-
As I know, the first method is return headers to clients, not send headers to that location. Anyway, thank you |
Beta Was this translation helpful? Give feedback.
-
This discussion was automatically locked because the community moved to a new site. Please join us at vercel.community |
Beta Was this translation helpful? Give feedback.
-
Question
Dear,
I want to ask that can we use vercel.json with this feature: proxy_set_header like nginx ?
I want to set some specific headers, such as Host, X-Forwarded-Host, Key_A(some stuff so I can verify that this request is from vercel)
Thank you
Beta Was this translation helpful? Give feedback.
All reactions