【问题标题】:Error with cordova security content after build构建后科尔多瓦安全内容出错
【发布时间】:2016-02-11 10:33:48
【问题描述】:

我正在使用 iOS 中的混​​合科尔多瓦应用程序,在最新版本的科尔多瓦中将此行添加到 headtag

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

当我在模拟器或设备中构建时返回此错误:

Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.

此错误出现在与服务器交互的时刻,阻塞了 ajax 请求。

我做错了什么?请帮忙!!!

【问题讨论】:

标签: ios cordova sencha-touch content-security-policy


【解决方案1】:

错误消息告诉您,您当前的内容安全策略禁止向您发出请求的域发出请求,因为您尚未指定允许这样做。将此包含在 CSP 标记中:-

script-src https://yourajaxdomainhere

这样就变成了

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

还要确保将您发送请求的域作为允许的来源添加到您的 config.xml 文件中。

<access origin="https://yourajaxdomainhere" />

More information on content security policy is here

【讨论】:

  • so.. 在我的 config.xml 我有 还不够吗?
猜你喜欢
  • 2017-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-25
  • 2015-07-18
相关资源
最近更新 更多