content security policy error, but meta-tag includes URL

天涯浪子 提交于 2019-12-01 12:17:47

问题


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:


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


来源:https://stackoverflow.com/questions/31256348/content-security-policy-error-but-meta-tag-includes-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!