Skip to content

feat(fetch-proxy): add X-Forwarded-Port header#11265

Merged
mjackson merged 1 commit intomainfrom
mjackson/fetch-proxy-x-forwarded-port
Apr 25, 2026
Merged

feat(fetch-proxy): add X-Forwarded-Port header#11265
mjackson merged 1 commit intomainfrom
mjackson/fetch-proxy-x-forwarded-port

Conversation

@mjackson
Copy link
Copy Markdown
Member

This keeps X-Forwarded-Host aligned with the original request Host value while adding a separate X-Forwarded-Port header when xForwardedHeaders is enabled. This follows the shape used by node-http-proxy and avoids changing existing consumers that expect the port to remain in X-Forwarded-Host.

Supersedes #10762.

  • Adds X-Forwarded-Port for proxied requests when xForwardedHeaders: true
  • Preserves the current X-Forwarded-Host behavior by continuing to use url.host
  • Uses explicit request ports when present and falls back to 80 or 443 for default HTTP/HTTPS ports
let proxy = createFetchProxy('https://backend.example', {
  xForwardedHeaders: true,
})

await proxy(new Request('http://shopify.com:8080/search'))
// X-Forwarded-Proto: http
// X-Forwarded-Host: shopify.com:8080
// X-Forwarded-Port: 8080

@github-actions
Copy link
Copy Markdown
Contributor

Preview Build Available

A preview build has been created for this PR. You can install it using:

pnpm install "remix-run/remix#preview/pr-11265&path:packages/remix"

This preview build will be updated automatically as you push new commits.

@mjackson mjackson merged commit b414d37 into main Apr 25, 2026
9 checks passed
@mjackson mjackson deleted the mjackson/fetch-proxy-x-forwarded-port branch April 25, 2026 07:09
@github-actions
Copy link
Copy Markdown
Contributor

The preview branch preview/pr-11265 has been deleted now that this PR is merged/closed.

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