Issue
I see Cross-Origin Resource Sharing (CORS) errors in the browser console and want those CORS details recorded and sent to Sentry.
Applies To
All SaaS Customers and Self-Hosted Users
JavaScript SDK (browser)
Error Monitoring
httpClientIntegration
Resolution
For security reasons, browsers do not expose CORS failure details to JavaScript. Your app code (and Sentry) only know that a request failed. The CORS reason text lives in the browser console, not in a JavaScript-accessible error object.
If you want failed fetch or XHR requests in Sentry, including requests that failed because of CORS, enable the optional httpClientIntegration. That captures failed network requests. It does not turn browser CORS console messages into CORS-labeled Sentry issues, and it creates events for failed requests in general, not CORS-only failures.
import * as Sentry from "@sentry/browser";Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [Sentry.httpClientIntegration()],
});
Narrow which failed requests become issues with integration options such as failedRequestStatusCodes and failedRequestTargets, or with SDK filtering or Inbound Filters. You cannot reliably keep "CORS only," because the browser does not tell JavaScript that the failure was CORS.
If the problem is Sentry rejecting your event submission with event submission rejected with_reason: Cors, that is a different issue. See How to handle "event submission rejected with_reason: Cors" errors.
For background on why CORS details stay in the console, see MDN’s CORS errors page (not built or maintained by Sentry).
