javascript - PHP/Apache:由于内容安全政策,拒绝加载谷歌“www.gstatic.com/charts/loader.js”脚本
问题描述
我正在编写一个 PHP 视图,该视图在 Apache 的 DocumentRoot 中以单个 HTML 显示 Google 图表,它可以工作,但是当我将相同的代码放入 PHP 页面时,浏览器会抛出如下异常:
它发生在通过 src 标签调用脚本时:
Refused to load the script 'https://www.gstatic.com/charts/loader.js'
because it violates the following Content Security Policy directive: "default-src 'self'".
Note that 'script-src-elem' was not explicitly set, so 'default-src' is used as a fallback.
它发生在行内脚本中,代码在页面中:
Refused to execute inline script because it violates the following Content Security Policy directive:
"default-src 'self'". Either the 'unsafe-inline' keyword,
a hash ('sha256-gCemxHcM8ctzTMqVc2498nRLFHED+rKI4ZaErIVSSk0='),
or a nonce ('nonce-...')
is required to enable inline execution.
Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
我的虚拟主机如下:php743.localhost.com
我一直在为应用程序内部和 Apache 寻找解决方案,但我无法修复它。
有任何想法吗?
解决方案
推荐阅读
- javascript - 将数据从表更新到数据库?
- laravel-backpack - 错误 403 禁止。此操作未经授权
- python - 在 python 中使用 glob 不返回最新的文件路径
- angularjs - Angular Bootstrap 如何使用 ng-click 导航特定选项卡
- coinbase-api - 无法获取市价单的价格
- symfony - AutoWire services_test.yaml -> 没有 ID 为“service.a”的节点
- nativescript - 包裹在布局中时,ScrollView 不起作用
- c# - 使用 Webclient 事件更新调用类
- mysql - YEAR(AVG(UNIX(date))) 不同于 ROUND(AVG(YEAR(date)))
- java - 具有泛型参数的重载方法