Skip to content

feat(core): Add support for x-forwarded-host and x-forwarded-proto headers #16687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 23, 2025

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Jun 23, 2025

Adds support for x-forwarded-host (host forwarding) and x-forwarded-proto (protocol forwarding).

This is useful when using proxies.

Closes #16671

Support for this was also added in this PR for Next.js

@s1gr1d s1gr1d requested review from RulaKhaled and mydea June 23, 2025 11:19
Copy link
Contributor

github-actions bot commented Jun 23, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.99 kB - -
@sentry/browser - with treeshaking flags 23.76 kB - -
@sentry/browser (incl. Tracing) 38.8 kB - -
@sentry/browser (incl. Tracing, Replay) 76.94 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.02 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 81.7 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 93.78 kB - -
@sentry/browser (incl. Feedback) 40.74 kB - -
@sentry/browser (incl. sendFeedback) 28.7 kB - -
@sentry/browser (incl. FeedbackAsync) 33.59 kB - -
@sentry/react 25.76 kB - -
@sentry/react (incl. Tracing) 40.79 kB - -
@sentry/vue 28.36 kB - -
@sentry/vue (incl. Tracing) 40.67 kB - -
@sentry/svelte 24.01 kB - -
CDN Bundle 25.5 kB - -
CDN Bundle (incl. Tracing) 38.88 kB - -
CDN Bundle (incl. Tracing, Replay) 74.79 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 80.26 kB - -
CDN Bundle - uncompressed 74.5 kB - -
CDN Bundle (incl. Tracing) - uncompressed 115.33 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 229.38 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 242.21 kB - -
@sentry/nextjs (client) 42.43 kB - -
@sentry/sveltekit (client) 39.29 kB - -
@sentry/node 150.82 kB +0.03% +37 B 🔺
@sentry/node - without tracing 98.58 kB +0.04% +33 B 🔺
@sentry/aws-serverless 124.34 kB +0.04% +38 B 🔺

View base workflow run

Comment on lines +208 to +210
'x-forwarded-proto': 'https',
},
protocol: 'http',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: Could you also add one test case for the reverse (protocol: https but forwarded: http) just to test that this isn't just accidentally passing because we always have https?

Copy link
Member

@andreiborza andreiborza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@s1gr1d s1gr1d merged commit 09aec61 into develop Jun 23, 2025
163 checks passed
@s1gr1d s1gr1d deleted the sig/node-forward-header branch June 23, 2025 14:53
andreiborza pushed a commit that referenced this pull request Jun 23, 2025
…` headers (#16687)

Adds support for
[x-forwarded-host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-Host)
(host forwarding) and
[x-forwarded-proto](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-Proto)
(protocol forwarding).

This is useful when using proxies. 

Closes #16671

Support for this was also added [in this PR for
Next.js](#16500)
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.

Event URL not using X-Forwarded-Proto and X-Forwarded-Host
2 participants