Skip to content

Commit 20aecfc

Browse files
committed
fix: use fetch transport for OTEL exporter instead of sendBeacon
sendBeacon can't perform CORS preflights, so cross-origin POSTs with Content-Type: application/json fail silently in Firefox (status null). Passing headers: {} triggers the SDK to select the fetch transport.
1 parent 66c2076 commit 20aecfc

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/telemetry.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ const WebSdkLive = collectorUrl
2626
? WebSdk.layer(() => ({
2727
resource: { serviceName: "postgres-garden-web" },
2828
spanProcessor: new BatchSpanProcessor(
29-
new OTLPTraceExporter({ url: `${collectorUrl}/v1/traces` }),
29+
new OTLPTraceExporter({
30+
url: `${collectorUrl}/v1/traces`,
31+
// Force fetch transport instead of sendBeacon — sendBeacon can't
32+
// do CORS preflights, which breaks cross-origin JSON POSTs.
33+
headers: {},
34+
}),
3035
),
3136
}))
3237
: WebSdk.layer(() => ({

0 commit comments

Comments
 (0)