report-uri and report-to Directives (report-uri / report-to)
Why You Should Care About report-uri / report-to
Violation reporting is essential for deploying security policies without breaking your site. When rolling out CSP, you can use Content-Security-Policy-Report-Only with a report-uri to see what would be blocked without affecting users. The reports show the blocked resource, the violated directive, and the page URL, helping you refine the policy.
Without reporting, deploying CSP is a trial-and-error process. You might miss edge cases that only occur for certain users, browsers, or page states. Reports provide data-driven visibility into policy effectiveness and false positives.
report-to is the newer mechanism that uses the Reporting API (configured via the Report-To header). It supports batching, retries, and priority, making it more reliable than report-uri. However, browser support varies, so setting both provides the best coverage. Services like report-uri.com, Sentry, and uriports.com can receive and aggregate these reports.
How to Test for report-uri / report-to
A security audit checks whether your CSP includes reporting directives. If you are deploying or iterating on your CSP, enable report-only mode with a reporting endpoint to collect violation data before enforcing the policy.
Run a Security Audit