【问题标题】:Header CSP (content-security-policy) not correct标头 CSP(内容安全策略)不正确
【发布时间】:2023-04-03 04:05:01
【问题描述】:

我的网站 javascript 出现问题,在主页上,引导程序中的下拉框将不起作用,但是在子目录上它似乎工作得非常好......我的 CSP 标题如下:

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

根据我对 CSP 文档的理解;空格将允许指令中的多个条目。 “脚本源”

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

错误:

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.

【问题讨论】:

    标签: javascript twitter-bootstrap http-headers


    【解决方案1】:

    固定为:

    $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);
    

    【讨论】:

      猜你喜欢
      • 2021-12-26
      • 2021-07-29
      • 1970-01-01
      • 2023-01-07
      • 1970-01-01
      • 2016-03-25
      • 2013-10-09
      • 2015-07-28
      • 1970-01-01
      相关资源
      最近更新 更多