script-src
- Job
- Which sources may supply JavaScript. Here only scripts carrying the matching nonce run
Content Security Policy (CSP) limits what a page may load and run. See the core directives, nonce versus hash, report-only rollout, and a quick curl check.
Content Security Policy (CSP) is an HTTP response header that tells the browser which sources a page may load scripts, images, frames and other resources from. It is mainly a defense against cross-site scripting. MDN recommends a strict policy built on per-response nonces over long allowlists.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
script-src'nonce-...'<script> tagobject-src 'none'base-uri 'none'<base> tagsframe-ancestorsX-Frame-Optionsdefault-srcContent-Security-Policy:
script-src 'nonce-416d1177-4d12-4e3b-b7c9-f6c409789fb8';
object-src 'none';
base-uri 'none';
frame-ancestors 'self'Directives are separated by semicolons. The first three lines above follow the strict CSP shape MDN recommends. The frame-ancestors line is our addition, so adjust it to your embedding needs.
sha256-, sha384-, sha512-)integrity attribute'strict-dynamic' lets a trusted script load further scripts, which eases third-party tags. MDN notes the trade-off: it weakens protection if those scripts create script elements from untrusted input.
Reporting-Endpoints: csp-endpoint="https://example.com/csp-reports"
Content-Security-Policy-Report-Only: default-src 'self'; report-to csp-endpointUse the Content-Security-Policy-Report-Only header. It generates reports without blocking anything. MDN says a report-only policy can't be delivered in a <meta> element.
Define an endpoint with Reporting-Endpoints and add report-to to the policy. MDN says report-uri is deprecated and suggests declaring both until report-to has full support.
Add nonces to legitimate scripts, remove inline handlers, and drop sources you don't use.
Rename the header to Content-Security-Policy. If both headers are present, MDN says both policies are honored.
A policy that blocks a script your pages need to render can change what crawlers see. After any change, test a key URL in the URL Inspection tool. For how CSP sits next to HSTS and the other headers, see security headers.
curl -sI https://example.com/ | grep -i 'content-security-policy'
curl -sI https://example.com/app.js | grep -i 'content-security-policy'
# no output on a route means that route sends no policy2 questions people ask next, answered from the sources on this page.
No. MDN says setting a CSP is not an alternative to sanitizing input, and sites should do both.
Yes, with limits. MDN says a <meta http-equiv> policy doesn't support all CSP features, and report-only policies can't be delivered that way. Prefer the header when you control the server.
The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.