Skip to main content

How do I configure my Content Security Policy (CSP) to allow Sentry?

Issue

My site uses a Content Security Policy (CSP), and I need to know which directives to add so Sentry can load and send events without being blocked by the CSP.

Applies To

  • All SaaS Customers and Self-Hosted Users

  • JavaScript SDK (Browser)

  • Session Replay

Resolution

The exact CSP you need depends on your site and which Sentry features you load, so there is no single value that fits every site. At a minimum, allow your application to send events to your Sentry ingestion endpoint by adding your DSN's host to the connect-src directive:

connect-src 'self' https://o<your-org-id>.ingest.<region>.sentry.io;

Use the host from your own DSN (found in Project Settings > SDK Setup > Client Keys (DSN)).

For feature-specific requirements, follow the documentation:

Note: Configuring your CSP to allow Sentry is different from using Sentry as a CSP report collector (Sentry receiving Content-Security-Policy, Expect-CT, and HPKP violation reports). To set that up, see Security Policy Reporting; to filter noisy CSP reports once you receive them, see How do I configure Content-Security-Policy (CSP) filters?.

Did this answer your question?