HTTP headers | ContentSecurityPolicyReportOnly (original) (raw)

HTTP headers | Content-Security-Policy-Report-Only

Last Updated : 9 Sep, 2025

Content-Security-Policy-Report-Only is an HTTP response header that lets developers test security policies without enforcing them. Any violations are logged as JSON reports and sent via HTTP POST to a specified URI.

**Syntax:

Content-Security-Policy-Report-Only:

**Directives: This header accepts a single header mentioned above and described below:

**Note: The report-uri directive is intended to be replaced by report-to directive, report-to is still not supported by most of the browsers. So, to tackle the compatibility issues, one can specify both report-uri and report-to as it would not only add compatibility with current browsers but also add forward compatibility when the browsers will get report-to support.

Content–Security-Policy: ….; report-uri https://written.geeksforgeeks.com; report-to groupname

The browsers supporting report-to will ignore report-uri.

**Examples:

The purpose of the header is to report any violations that might have occurred. It can be used iteratively to work upon a content security policy. One can observe how their site behaves, watching for **violation reports and/or **malware redirects, then choose the appropriate policy imposed by Content-Security-Policy header.

Content-Security-Policy-Report-Only: default-src https:; report-uri /csp-violation-report-endpoint/

If one wishes to receive reporting while still imposing the policy, they can use Content-Security-Policy header with report-uri directive.

Content-Security-Policy: default-src https:; report-uri /csp-violation-report-endpoint/

To check this Content-Security-Policy-Report-Only in action go to

**Inspect Element -> Network

check the request header for Content-Security-Policy-Report-Only like below, Content-Security-Policy-Report-Only is highlighted you can see.

**Violation report syntax:

The JSON report contains the following data:

**Sample violation report: The page located at http://geeksforgeeks.com/signup.html. Below is the policy implemented, that only allows the stylesheet from cdn.geeksforgeeks.com.

Content-Security-Policy-Report-Only: default-src ‘none’; style-src cdn.geeksforgeeks.com; report-uri /_/csp-reports

**Supported Browsers: The browsers are compatible with **HTTP Content-Security-Policy-Report-Only headers are listed below: