Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async function convertFromAPIGatewayProxyEvent(
type: "core",
method: httpMethod,
rawPath: path,
url: `https://${headers.host ?? "on"}${path}${normalizeAPIGatewayProxyEventQueryParams(event)}`,
url: `https://${headers["x-forwarded-host"] ?? "on"}${path}${normalizeAPIGatewayProxyEventQueryParams(event)}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not 100% correct either, we could create an helper function that would retrieve the host from the headers.
If this header is not set (which can be the case), we should fallback to the host header

Copy link
Contributor Author

@vicb vicb Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean an helper to headers["x-forwarded-host"] ?? headers.on ?? "on" ?
For all aws converters?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my original idea, but i think there is a better solution (#752 (comment)). In the converters we keep headers.host ?? "on", but in the routing handler if we have a x-forwarded-host header, we change both the host header and the internalEvent.url

body: Buffer.from(body ?? "", isBase64Encoded ? "base64" : "utf8"),
headers,
remoteAddress: requestContext.identity.sourceIp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function convertFromAPIGatewayProxyEventV2(
type: "core",
method: requestContext.http.method,
rawPath,
url: `https://${headers.host ?? "on"}${rawPath}${rawQueryString ? `?${rawQueryString}` : ""}`,
url: `https://${headers["x-forwarded-host"] ?? "on"}${rawPath}${rawQueryString ? `?${rawQueryString}` : ""}`,
body: normalizeAPIGatewayProxyEventV2Body(event),
headers,
remoteAddress: requestContext.http.sourceIp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async function convertFromCloudFrontRequestEvent(
type: "core",
method,
rawPath: uri,
url: `https://${headers.host ?? "on"}${uri}${querystring ? `?${querystring}` : ""}`,
url: `https://${headers["x-forwarded-host"] ?? "on"}${uri}${querystring ? `?${querystring}` : ""}`,
body: Buffer.from(
body?.data ?? "",
body?.encoding === "base64" ? "base64" : "utf8",
Expand Down