Content-Security-Policy
Content-Security-Policy (CSP) is an HTTP response header that holds a list of rules for a page. The browser blocks each script, frame, image, or other load that the rules do not allow.
HTTP header
Also called CSP
Updated
On this page
Example
HTTP response header
Content-Security-Policy: default-src 'self'; img-src 'self' https://cdn.example.com; frame-ancestors 'self' https://partner.example
The page loads content only from its own origin, plus images from one CDN. Only its own site and https://partner.example may frame it.
How to set it
Send the policy as an HTTP response header. Put all directives in one header and separate them with semicolons.
Content-Security-Policy: default-src 'self'; frame-ancestors 'self'
A policy in a meta tag ignores frame-ancestors, report-uri, and sandbox. If a response has two policies, the browser enforces both, so a load must pass each one.
Learn more
Sources