content security policy error, but meta-tag includ

2019-02-20 20:32发布

Why am I receiving errors like this?

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'".

my meta-tag:

<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条回答
疯言疯语
2楼-- · 2019-02-20 20:40

Seems like I needed explicit URI-scheme. This work:

<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
">
查看更多
登录 后发表回答