Content-Security-Policy的内容可以包含以下指令1:
Content-Security-Policy: default-src http://example.com
会阻止加载除了 http://example.com
以外的任何资源。Content-Security-Policy: script-src https://example.com
会阻止执行任何非 https://example.com
的脚本。每一个指令后面都应该有一个或多个源,多个源之间使用空格分隔。如果需要允许所有来源的资源,可以使用 *
。例如, Content-Security-Policy: script-src *
会允许从所有源加载脚本。