尝试加载 js 文件时出现此错误
Refused to load the script 'http://192.168.1.10/js/test.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval'
我应该使用什么策略?
这是我的元数据
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
以及config.xml中的白名单(root)
<access origin="http://192.168.1.10/*" />
<allow-navigation href="http://192.168.1.10/*" />
<allow-intent href="http://192.168.1.10/*" />
我正在平台 cordova 5 上构建,[email protected]并在Android 5.1.1上进行测试
最佳答案
找到了解决方案,我想我会发布;我只是忘记将 URL 添加到元中。
<meta http-equiv="Content-Security-Policy"
content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' http://192.168.1.10">
关于javascript - Cordova 5白名单、Content-Security-Policy和本地网络ip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30645057/