Skip to content

fix(sdk/abTesting): preserve original Host when proxying to fallback origin#308

Open
hugo-ccabral wants to merge 1 commit into
mainfrom
fix/proxy-fallback-preserve-host
Open

fix(sdk/abTesting): preserve original Host when proxying to fallback origin#308
hugo-ccabral wants to merge 1 commit into
mainfrom
fix/proxy-fallback-preserve-host

Conversation

@hugo-ccabral

@hugo-ccabral hugo-ccabral commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Problem

proxyToFallback rewrites the target URL to the fallbackOrigin and drops the incoming Host header, so the upstream receives Host: <fallbackOrigin>.

Shared fallback origins route by Host — the EKS ingress LB behind decoserverless.deco.site serves many sites and picks the site from the Host header. 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 (worker storefront-tanstack, ratio: 0 → 100% fallback): every request returned the EKS 404 page, tagged x-deco-bucket: fallback. Hitting the AWS LB directly with Host: storefront.deco.site works, 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-host is 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)
  • Bundled into storefront-tanstack and verified the built worker contains the Host-preserving proxy; live verification via companion PR on deco-sites/storefront-tanstack pointing at this commit

🤖 Generated with Claude Code


Summary by cubic

Preserves the site's original Host header when proxyToFallback proxies to the fallback origin, fixing 404s on shared fallback load balancers that route by Host. Continues to strip hop-by-hop headers, sets x-forwarded-host, and updates tests accordingly.

Written for commit b5b313e. Summary will update on new commits.

Review in cubic

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant