You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/javascript/common/tracing/distributed-tracing/dealing-with-cors-issues/index.mdx
+89-3Lines changed: 89 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -16,8 +16,94 @@ notSupported:
16
16
- javascript.nestjs
17
17
---
18
18
19
-
If your frontend and backend are hosted on different domains (for example, your frontend is on `https://example.com` and your backend is on `https://api.example.com`), and the frontend does XHR/fetch requests to your backend, you'll need to configure your backend [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers) headers to ensure requests aren't blocked.
19
+
If your frontend and backend are hosted on different domains (for example, your frontend is on `https://example.com` and your backend is on `https://api.example.com`), you may need to configure your backend [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers) headers to ensure distributed tracing works properly.
20
20
21
-
Configure your backend CORS to allow the `sentry-trace` and `baggage` headers.
21
+
## Understanding Trace Propagation
22
22
23
-
Your server's response header configuration might look like: `"Access-Control-Allow-Headers: sentry-trace, baggage"`. Your configuration will be specific to your setup.
23
+
Sentry doesn't attach the `sentry-trace` and `baggage` headers to every outgoing request. Instead, it only attaches these headers to requests whose URLs match the patterns specified in the `tracePropagationTargets` configuration option.
24
+
25
+
**By default**, `tracePropagationTargets` is set to `['localhost', /^\//]`, which means trace headers are only attached to:
26
+
- Requests containing `localhost` in their URL (e.g., `http://localhost:3000/api`)
27
+
- Requests whose URL starts with `/` (e.g., `/api/users`, `/graphql`)
28
+
29
+
This default behavior helps prevent sending trace data to third-party services and reduces potential CORS issues.
30
+
31
+
## Configuring Trace Propagation
32
+
33
+
To enable distributed tracing across different domains, you need to configure `tracePropagationTargets` to include the URLs of your backend services:
0 commit comments