sentry-javascript: 7.17.1 attaching baggage header to third-party requests breaking CORS policies
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
SDK Version
7.17.1
Framework Version
React 16.x
Link to Sentry event
No response
Steps to Reproduce
Our app was running fine using sentry/tracing 7.16.0 We deployed new code with sentry/tracing 7.17.1 A bunch of third party requests started failing with CORS errors: blocked by CORS policy: Request header field baggage is not allowed by Access-Control-Allow-Headers in preflight response. We roll back to previous version, errors go away
in our test environment, with Sentry enabled and sentry/tracing at 7.17.1, CORS errors on third party requests to services on other domains that we don’t control with Sentry disabled, everything is fine with Sentry/tracing on 7.16.0 and enabled, everything is fine
Expected Result
No CORS errors on third-party requests, no baggage header attached to third party requests
Actual Result
request has been blocked by CORS policy: Request header field baggage is not allowed by Access-Control-Allow-Headers in preflight response.
I have to assume this was caused by https://github.com/getsentry/sentry-javascript/pull/6039 We use default tracing config
new TracingIntegrations.BrowserTracing(),
Which according to the docs: https://docs.sentry.io/platforms/javascript/performance/instrumentation/automatic-instrumentation/#tracingorigins should only impact calls to localhost and the same domain/origin as the page, but this does not seem to be happening
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 38 (15 by maintainers)
Commits related to this issue
- fix(tracing): Fix `tracingOrigins` not applying (#6079) In the process of working on https://github.com/getsentry/sentry-javascript/issues/5285, we missed the fact that the first two PRs (https://git... — committed to getsentry/sentry-javascript by lobsterkatie 2 years ago
- Fix Sentry baggage header causing Network Error... https://github.com/getsentry/sentry-javascript/issues/6077 — committed to amcsi/lycee-overture by amcsi a year ago
Hi @redbugz,
we just released version 7.17.2 with a fix for this bug.
@Lms24 everything is ok, it works. Thanks!
I thought the same until I read the type declarations:
We got this error even with
7.61.1. We fixed it by adding:To prevent
fetchcalls for being traced (hence adding the headers).fixed, the following additional headers should be added in backend:
‘baggage’, ‘sentry-trace’… You must add all the headers that request sentinel or those that exit in error that are being blocked to the backend.
Here, trying to integrate sentry with next js 12. It happens to me that when installing sentry it generates this error:
Access to XMLHttpRequest at ‘http://localhost:1337/api/auth/local’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: Request header field baggage is not allowed by Access-Control-Allow-Headers in preflight response.
now when I add BrowserTracing, it works correctly for me only when logging in but the rest of the endpoints again get the same error cors
I tried disabling
traceFetchandtraceXHRto fix this. According to the docs for those options it should have.So what do I have to do to stop Sentry from modifying my requests altogether?
Hi @Archi4400 we released 7.21.0 with the fix. The issue was auto-closed after merging it. Let me know if
tracePropagationTargetsnow work for you. Thanks!