Skip to content

Commit

Permalink
fix(api-server): Preserve original host header for proxied API reques…
Browse files Browse the repository at this point in the history
…ts (#10082)

Co-authored-by: Daniel Choudhury <[email protected]>
  • Loading branch information
2 people authored and jtoar committed Mar 7, 2024
1 parent 2ada8ef commit cdc64aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# CHANGELOG

## Unreleased
- fix(api-server): Preserve original host header for proxied API requests
Some apps rely on reading the host header(eg multi-tenant apps served over multiple subdomains). This change forwards on the original host header on proxied Fastify requests, and the experimental SSR/RSC server

- fix(context): Re-export context from graphql-server (#10117)

Expand Down
7 changes: 7 additions & 0 deletions packages/adapters/fastify/web/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ export async function redwoodFastifyWeb(
prefix: redwoodOptions.apiUrl,
upstream: redwoodOptions.apiProxyTarget,
disableCache: true,
replyOptions: {
rewriteRequestHeaders: (req, headers) => ({
...headers,
// preserve the original host header, instead of letting it be overwritten by the proxy
host: req.headers.host,
}),
},
})
}

Expand Down

0 comments on commit cdc64aa

Please sign in to comment.