-
Notifications
You must be signed in to change notification settings - Fork 988
unset host, if set, before sending proxy cloud run/functions request #3025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved but please address one comment.
src/hosting/proxy.ts
Outdated
@@ -68,6 +68,11 @@ export function proxyRequestHandler(url: string, rewriteIdentifier: string): Req | |||
Cookie: sessionCookie || "", | |||
}); | |||
for (const key of Object.keys(req.headers)) { | |||
// Skip particular header keys: | |||
// - using x-forwarded-host, don't need to keep `host` in the headers. | |||
if (["host"].includes(key)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ["host"].includes(key)
and not key === "host"
? Was this maybe a longer list at first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a headers.delete("host")
below before but didn't want that as a pattern. I figured being able to have a list here would be great just in case there were other headers a proxy shouldn't actually be sending.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then maybe do two lines:
const headersToDelete = ["host"];
if (headersToDelete.includes(key)) {
Description
I cannot keep
host
set while proxying as it breaks the outbound request since it won't match the URL we're going for.Fixes #3012
Scenarios Tested