Skip to content

transportOptions not setting headers #7169

@martinkwan

Description

@martinkwan

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using? If you use the CDN bundles, please specify the exact bundle (e.g. bundle.tracing.min.js) in your SDK setup.

@sentry/react

SDK Version

7.22.0

Framework Version

React 17.0.2

Link to Sentry event

No response

SDK Setup

  Sentry.init({
    dsn: this.sentryKey,
    release: this.releaseTag,
    environment: process.env.NODE_ENV,
    integrations: [
      new BrowserTracing({
        tracingOrigins: [],
        routingInstrumentation: Sentry.reactRouterV5Instrumentation(
          HISTORY_SINGLETON,
          getRouteConfigsForSentryPerf([
            ...Object.values(FLAT_ROUTES),
            ...Object.values(DeprecatedROUTES),
          ]),
          matchPath,
        ),
        shouldCreateSpanForRequest: (url) => {
          const gqlUrl = HttpRequestUtil.getGqlUrl();
          const isGqlUrl = url === gqlUrl;
          return !isGqlUrl;
        },
        _metricOptions: {
          _reportAllChanges: true,
        },
        heartbeatInterval: 10000,
      }),
    new Sentry.Integrations.Breadcrumbs({console: false}),
    ],
tracesSampleRate: 1,
transportOptions: {
  headers: {'Origin': 'test.com'},
}});

Steps to Reproduce

  1. Open Network request tab
  2. Origin is not changed (is still http://localhost:3000)
    Screen Shot 2023-02-13 at 5 28 30 PM

Is there a way to change or hide the origin header? My goal is to hide the origin header as it contains sensitive data.

Expected Result

Origin header is changed to test.com

Actual Result

Origin header is not changed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions