feat(custom-headers): add SENTRY_CUSTOM_HEADERS for self-hosted proxy auth#761
feat(custom-headers): add SENTRY_CUSTOM_HEADERS for self-hosted proxy auth#761
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8daba02. Configure here.
… auth Add support for injecting custom HTTP headers into all requests to self-hosted Sentry instances behind reverse proxies (e.g., Google IAP, Cloudflare Access). Two mechanisms are provided: - `SENTRY_CUSTOM_HEADERS` env var for CI/scripting - `sentry cli defaults headers` for persistent local config Format: semicolon-separated `Name: Value` pairs (newlines also work). Headers are only applied when targeting self-hosted instances; ignored with a warning on SaaS (*.sentry.io). Custom headers are injected at three request paths: - Authenticated API requests (via prepareHeaders in sentry-client.ts) - OAuth device flow (via fetchWithConnectionError in oauth.ts) - Shared issue resolution (via getSharedIssue in api/issues.ts) Closes #759
…DERS example
The example field should contain only the value, not the variable name,
since the doc generator produces `export ${name}=${example}`.
The DefaultsState type now includes `headers`, so toEqual assertions need the field to pass strict deep equality checks.
22840e3 to
734f86d
Compare
|
Codecov Results 📊✅ 134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 96.10%. Project has 1639 uncovered lines. Files with missing lines (2)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.45% 95.45% —%
==========================================
Files 236 237 +1
Lines 35923 36049 +126
Branches 0 0 —
==========================================
+ Hits 34290 34410 +120
- Misses 1633 1639 +6
- Partials 0 0 —Generated by Codecov Action |

Summary
Adds support for injecting custom HTTP headers into all requests to self-hosted Sentry instances behind reverse proxies (e.g., Google IAP, Cloudflare Access).
SENTRY_CUSTOM_HEADERSenv var — for CI/scripting overridessentry cli defaults headers— for persistent local configurationFormat: semicolon-separated
Name: Valuepairs (newlines also accepted as separators).Self-hosted only
Custom headers are only applied when targeting a self-hosted instance (
SENTRY_HOST/SENTRY_URLis set to a non-*.sentry.ioURL). When configured on SaaS, headers are ignored with a one-time warning.Injection points
Headers are injected at all three request paths to the Sentry server:
prepareHeaders()insentry-client.tsfetchWithConnectionError()inoauth.ts(fixes the login error from the issue)getSharedIssue()inapi/issues.tsResolution priority
SENTRY_CUSTOM_HEADERSenv var >defaults.headersin SQLite > noneReserved headers
Authorization,Host,Content-Type,Content-Length,User-Agent,sentry-trace,baggage— these are managed by the CLI and cannot be overridden.Usage
Closes #759