diff --git a/packages/browser/src/backend.ts b/packages/browser/src/backend.ts index d6dfe5d25ddc..4cdef3d11047 100644 --- a/packages/browser/src/backend.ts +++ b/packages/browser/src/backend.ts @@ -3,7 +3,7 @@ import { Event, EventHint, Options, Severity, Transport, TransportOptions } from import { supportsFetch } from '@sentry/utils'; import { eventFromException, eventFromMessage } from './eventbuilder'; -import { FetchTransport, makeNewFetchTransport, XHRTransport } from './transports'; +import { FetchTransport, makeNewFetchTransport, makeNewXHRTransport, XHRTransport } from './transports'; /** * Configuration options for the Sentry Browser SDK. @@ -77,6 +77,11 @@ export class BrowserBackend extends BaseBackend { this._newTransport = makeNewFetchTransport({ requestOptions, url }); return new FetchTransport(transportOptions); } + + this._newTransport = makeNewXHRTransport({ + url, + headers: transportOptions.headers, + }); return new XHRTransport(transportOptions); } } diff --git a/packages/browser/src/transports/new-xhr.ts b/packages/browser/src/transports/new-xhr.ts index 7f9cad6cdfa1..cd19b1de0cd4 100644 --- a/packages/browser/src/transports/new-xhr.ts +++ b/packages/browser/src/transports/new-xhr.ts @@ -18,7 +18,7 @@ import { SyncPromise } from '@sentry/utils'; const XHR_READYSTATE_DONE = 4; export interface XHRTransportOptions extends BaseTransportOptions { - headers?: Record; + headers?: { [key: string]: string }; } /**