拒绝加载脚本,因为它违反了以下内容安全策略指令 [英] Refused to load the script because it violates the following Content Security Policy directive

查看:5494
本文介绍了拒绝加载脚本,因为它违反了以下内容安全策略指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试图部署我的应用程序到Android系统5.0.0以上的设备,我一直得到这样的错误消息:

Hi when I tried to deploy my app onto devices with android system above 5.0.0, I kept getting this kind of error messages:


07-03 18:39:21.621:D / SystemWebChromeClient(9132):
file:///android_asset/www/index.html:行0:拒绝加载
脚本' http:// xxxxx ,因为它违反了以下内容
安全策略伪指令:script-src'self''unsafe-eval'
'不安全在线'。 07-03 18:39:21.621:I / chromium(9132):
[INFO:CONSOLE(0)]拒绝加载脚本 http: / xxx ,因为
违反了以下内容安全策略指令:script-src
'self''unsafe-eval''unsafe-inline'。

07-03 18:39:21.621: D/SystemWebChromeClient(9132): file:///android_asset/www/index.html: Line 0 : Refused to load the script 'http://xxxxx' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' 'unsafe-inline'". 07-03 18:39:21.621: I/chromium(9132): [INFO:CONSOLE(0)] "Refused to load the script 'http://xxx' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' 'unsafe-inline'".

但是,如果我将它部署到Android系统4.4.x的移动设备,安全策略使用默认的策略:

However, if I deployed it to mobile device with android system of 4.4.x, the security policy works with default ones:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">

然后我想,也许我应该换成这样:

Then I thought, maybe, i should change to something like this:

<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-eval' 'unsafe-inline'; object-src 'self'; style-src 'self' 'unsafe-inline'; media-src *">

基本上,这两个选项都不适用于我。如何解决这个问题?

Basically, both option doesn't work for for me. Does anybody have an idea of how to solve this issue?

谢谢!

推荐答案

p>用

script-src 'self' http://xxxx 'unsafe-inline' 'unsafe-eval'; 

这篇关于拒绝加载脚本,因为它违反了以下内容安全策略指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆