Skip to content

Commit

Permalink
feat: support x-forwarded-host in ssr setup (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
misl-smlz authored Jul 18, 2024
1 parent 48e4410 commit 18fcc04
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/adapter/src/lambda/handlers/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ const createExports = (
headers.set("cookie", event.cookies.join("; "))
}

const domainName = headers.get("x-forwarded-host") ?? event.requestContext.domainName;
const qs = event.rawQueryString.length ? `?${event.rawQueryString}` : ""
const url = new URL(
`${event.rawPath.replace(/\/?index\.html$/u, "")}${qs}`,
`https://${event.requestContext.domainName}`,
`https://${domainName}`,
)

const request = new Request(url, {
Expand All @@ -132,7 +133,7 @@ const createExports = (

if (!routeData) {
const request404 = new Request(
new URL(`404${qs}`, `https://${event.requestContext.domainName}`),
new URL(`404${qs}`, `https://${domainName}`),
{
body: createRequestBody(
event.requestContext.http.method,
Expand Down

0 comments on commit 18fcc04

Please sign in to comment.