Header CSP (content-security-policy) 不正确

Header CSP (content-security-policy) not correct

我的网站 javascript 有问题,在主页上,bootstrap 中的下拉框无法使用,但是在 sub-directory 中它似乎工作得很好。 .. 我的 CSP header 如下:

script-src 'self' //ajax.cloudflare.com

根据我对 CSP 文档的理解;空格将允许指令中有多个条目。 "script-src"

我不明白为什么它在主页上不起作用。我在这里不知所措。

错误:

index.php:10 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' //ajax.cloudflare.com". Either the 'unsafe-inline' keyword, a hash ('sha256-safag'), or a nonce ('nonce-...') is required to enable inline execution.

修正:

$cspheader = "'default-src':'none' 'script-src':'self' 'unsafe-eval' //ajax.cloudflare.com/'font-src': 'self' 'connect-src':'self' 'img-src':'self' 'style-src':'self' 'media-src':'self'";
 header("Content-Security-Policy: ". $cspheader);