Knowledge base

Roll out a Content Security Policy safely in three steps

A Content Security Policy (CSP) tells browsers which scripts, styles and other resources your pages may load. A wrong policy can break your site, so Protectory helps you roll one out in three steps on the project's CSP tab.

The recommended policy

After a full scan, Protectory builds a policy from what the scan saw on your pages: script hosts, stylesheets, fonts, images, frames, form targets, and the Supabase or Firebase endpoints your app talks to. It never adds 'unsafe-inline'; inline scripts are listed by their sha256 hash, and the notes explain when nonces are the better choice. You get a copy-ready snippet for your hosting (Vercel, Netlify, Cloudflare, Nginx, Apache, WordPress, Next.js) and a fix prompt for your AI tool.

The scan can only see the pages it crawled. Pages behind a login or scripts loaded later may need extra entries; that is what step 2 finds.

1. Report-only

Deploy the policy as Content-Security-Policy-Report-Only with the report address shown on the page. Nothing is blocked; browsers only report what would have been blocked.

2. Watch for 7 days

Protectory groups the reports by directive and blocked origin. For an origin you trust, click Allow this origin: a new policy version is created (older versions stay in the history). Inline code and eval cannot be allowed with a click; fix them in code with a nonce or hash.

Only counts are kept: the page path without its query string, the blocked origin and the directive - no IP addresses, no browser details. Reports are kept 30 days. Report collection needs a verified domain and a paid or lifetime plan; the policy builder works on every plan.

3. Enforce

When no new kind of violation has appeared for 72 hours, the page suggests switching the header name to Content-Security-Policy. Keep the report address so you notice future problems. The next full scan detects the enforced header.

See also Security headers and cookies.

Last reviewed Oct 14, 2026, 12:00:00 AM

Still stuck? Send a ticket

Feedback
Type