Content-Security-Policy (CSP) Starter Playbook Without Breaking Production Scripts
Roll out a realistic Content-Security-Policy using Report-Only telemetry first, then lock down framing, object-src, base-uri, and third-party script origins.
Start with Content-Security-Policy-Report-Only
Shipping a strict CSP blindly on a live SaaS or marketing site can silently break Stripe checkout, analytics, or inline Next.js hydration scripts. Always deploy Content-Security-Policy-Report-Only first to observe violation reports in browser DevTools and telemetry logs.
A practical baseline CSP you can enforce immediately
Even before adopting cryptographic nonces for every inline script, you can enforce high-value invariants right away: frame-ancestors none (clickjacking defense), object-src none (Flash/plugin block), base-uri self, and upgrade-insecure-requests.
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://js.stripe.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' https://api.example.com; frame-ancestors 'none'; object-src 'none'; base-uri 'self'; upgrade-insecure-requestsPair CSP with Subresource Integrity (SRI) on external CDN scripts
Whenever you load a static third-party library from a CDN (unpkg, jsDelivr, cdnjs), include integrity="sha384-..." and crossorigin="anonymous" so compromised CDN packages cannot execute tampered code.
Check if your domain already passes these requirements
Run a 15-second live compliance scan across Privacy, EAA 2025, Email Auth, and Security Headers—or generate exact configs using our 6 free tools.