javascript - Cordova 5白名单、Content-Security-Policy和本地网络ip

标签 javascript cordova

尝试加载 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/

相关文章:

javascript - 需要在Datalist中实现javascript验证

javascript - 隐藏中心的同时保留开始和结束的子字符串函数

javascript - WordPress图像轮播显示空白图像

android - 触摸屏幕时图像像素化

javascript - 使用phonegap在jquery mobile中链接页面/加载javascript的最佳实践是什么?

javascript - 将 Knockout observableArray JSON 保存到 localStorage

javascript - HTML Canvas 和 Javascript - 模拟悬停滚动事件

android - 如何使用 Android phonegap 应用程序的拖放功能

cordova - iOS 11.3 中 PWA 无推送通知限制的解决方法?

ios - 应用程序部署到 App Store 后的 Worklight 6.1 "access to protected services is denied"