fix(sdk/abTesting): preserve original Host when proxying to fallback origin#308
Open
hugo-ccabral wants to merge 1 commit into
Open
fix(sdk/abTesting): preserve original Host when proxying to fallback origin#308hugo-ccabral wants to merge 1 commit into
hugo-ccabral wants to merge 1 commit into
Conversation
…origin proxyToFallback rewrote the target URL to the fallback origin and dropped the incoming Host header, so shared fallback origins that route by Host (e.g. the EKS ingress LB behind decoserverless.deco.site) received Host: <fallbackOrigin> and answered 404 for every proxied request. Forward Host: <site hostname> explicitly instead — same behavior as the original cf-dispatch gateway, which forwarded incoming headers untouched and is production-proven against the same LB. x-forwarded-host is still set and hop-by-hop stripping is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
proxyToFallbackrewrites the target URL to thefallbackOriginand drops the incomingHostheader, so the upstream receivesHost: <fallbackOrigin>.Shared fallback origins route by
Host— the EKS ingress LB behinddecoserverless.deco.siteserves many sites and picks the site from theHostheader. With the header dropped, every proxied fallback request lands with the LB's own hostname and the ingress answers 404.Observed live on
storefront.deco.site(workerstorefront-tanstack,ratio: 0→ 100% fallback): every request returned the EKS 404 page, taggedx-deco-bucket: fallback. Hitting the AWS LB directly withHost: storefront.deco.siteworks, proving the origin routes by Host.Fix
Forward
Host: <site hostname>(url.hostname) explicitly on the proxied request. This mirrors the original cf-dispatch gateway, which forwarded the incoming headers (Host included) untouched and is production-proven against this same LB.x-forwarded-hostis still set; hop-by-hop stripping is unchanged.Testing
vitest run src/sdk/abTesting.test.ts— 17/17 pass (updated the test that asserted Host was dropped)storefront-tanstackand verified the built worker contains the Host-preserving proxy; live verification via companion PR ondeco-sites/storefront-tanstackpointing at this commit🤖 Generated with Claude Code
Summary by cubic
Preserves the site's original Host header when
proxyToFallbackproxies to the fallback origin, fixing 404s on shared fallback load balancers that route by Host. Continues to strip hop-by-hop headers, setsx-forwarded-host, and updates tests accordingly.Written for commit b5b313e. Summary will update on new commits.