内容安全策略错误,但元标记包含URL

时间:2015-07-06 21:56:01

标签: android ionic-framework content-security-policy

为什么我收到这样的错误?

Refused to load the script 'http://maps.googleapis.com/maps/api/js?v=3&sensor=false'


because it violates the following Content Security Policy directive: 
"script-src 'self' *.googleapis.com 'unsafe-inline' 'unsafe-eval'".

我的元标记:

<meta http-equiv="Content-Security-Policy" 
content="default-src *; style-src 'self' *.googleapis.com 'unsafe-inline'; script-src 'self' *.googleapis.com 'unsafe-inline' 'unsafe-eval'">

1 个答案:

答案 0 :(得分:5)

似乎我需要显式的URI方案。这项工作:

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