它违反了以下内容安全政策指令

Posted

技术标签:

【中文标题】它违反了以下内容安全政策指令【英文标题】:it violates the following Content Security Policy directive 【发布时间】:2016-01-14 20:00:09 【问题描述】:

我刚开始学习 Cordova。我根据this url创建了一个项目。这个项目在Ripple模拟器中运行正常。但是当我尝试在Google android Emulator中运行它时。它无法获取天气,并显示以下信息:

Refused to connect to 'https://query.yahooapis.com/v1/public/yql?q=select+*+from+weather.forecast+where+location=98052&format=json' because it violates the following Content Security Policy directive: "default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.

jquery-2.1.4.min.js (4,14349)

我是否应该采取其他措施让这个项目在 Google Android Emulator 中正常运行。

【问题讨论】:

感谢 Lakhan 帮助编辑此问题。 【参考方案1】:

检查一下:

http://content-security-policy.com/#source_list

修复:

在源应用目录中:

www\index.html

https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline';媒体源 *">

我把'self'改成'*'

content="default-src *

【讨论】:

以上是关于它违反了以下内容安全政策指令的主要内容,如果未能解决你的问题,请参考以下文章

拒绝加载图像“blob:...”,因为它违反了以下内容安全政策

拒绝框架'https://api.xxx.jp/',因为它违反了以下内容安全策略指令:“frame-src'self'

拒绝应用内联样式,因为它违反了以下内容安全策略指令

拒绝加载脚本,因为它违反了以下内容安全策略指令

JQuery 3.5.1 并拒绝执行内联脚本,因为它违反了以下内容安全策略指令:

拒绝执行内联脚本,因为它违反了以下内容安全策略指令:“script-src 'self'”