Guides

How to use Content-Security-Policy-Report-Only

The report-only header tells browsers to report what a policy would have blocked, and to load it anyway. Use it to find everything your site depends on before you enforce a policy.

A first header to use

Start with a policy that is stricter than you expect to end up with. You want it to report anything that is not your own.

Reporting-Endpoints: default="https://YOUR-ID.cspinbox.com/r"
Content-Security-Policy-Report-Only: default-src 'self'; object-src 'none';
  base-uri 'self'; frame-ancestors 'self';
  report-uri https://YOUR-ID.cspinbox.com/csp/ro; report-to default

Each header has to be one line when you send it. It is split here to fit. How to add a CSP header covers nginx, Apache, Express and others.

Where the reports go

Without report-uri or report-to, violations only appear in each visitor's own developer console, where you will not see them. Set both, because browsers differ. report-uri and report-to compared explains why.

The address can be your own server or a service such as CSP Inbox. If you write your own, expect a lot of duplicates: one missing source sends a report on every page view.

How long to leave it running

A week or two is usual. Make sure it covers:

  • every type of page, including checkout, account and error pages
  • pages only some people see, such as admin screens
  • each browser you support, and mobile as well as desktop
  • anything that runs on a schedule, such as a campaign tag or a weekly A/B test

Moving to an enforced policy

  1. Add the sources you recognise, and investigate the ones you do not.
  2. Replace inline scripts with files, nonces or hashes.
  3. Send the new policy as report-only until only noise is left.
  4. Rename the header to Content-Security-Policy and keep reporting on.

You will never get to zero. Browser extensions and antivirus software cause reports on every site. How to read a CSP report covers how to tell them apart.

Running both headers at once

You can send Content-Security-Policy and Content-Security-Policy-Report-Only together. Browsers apply each one separately, so you can enforce a policy that works and try a stricter one alongside it.

Content-Security-Policy: script-src 'self' https://js.stripe.com 'unsafe-inline'; …
Content-Security-Policy-Report-Only: script-src 'self' https://js.stripe.com; …

Here the site keeps working with inline scripts while you find out which ones are left.

What it cannot do

  • It does not work in a <meta> tag. It has to be a response header.
  • It ignores the sandbox directive.
  • It only reports what real visitors run into. A page nobody opens is a page you learn nothing about.

Last checked 24 November 2026.

Read next