javascript - phonegap + ionic 使用 Content-Security-Policy 加载 maps.googleapis.com,如何?

标签 javascript google-maps firebase phonegap-plugins content-security-policy

我尝试了很多加载谷歌地图和 firebaseio 的方法,但都没有成功: 这就是我现在拥有的:

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

我得到:

Refused to load the script 'https://maps.googleapis.com/maps/api/js?libraries=places' because it violates the following Content Security Policy directive: "script-src 'self' https://maps.googleapis.com/* 'unsafe-inline' 'unsafe-eval'".

Refused to load the script 'https://test.firebaseio.com/.lp?start=t&ser=79549912&cb=1&v=5' because it violates the following Content Security Policy directive: "script-src 'self' https://maps.googleapis.com/* 'unsafe-inline' 'unsafe-eval'".

知道我做错了什么吗?

最佳答案

这成功了:)

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

和谷歌脚本 <script src="https://maps-api-ssl.google.com/maps/api/js?libraries=places"></script>

关于javascript - phonegap + ionic 使用 Content-Security-Policy 加载 maps.googleapis.com,如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31354685/

相关文章:

javascript - 在 PubNub 中更新客户端的 UUID

ios - 使用 Google Maps SDK 的哪个方法,例如 MapKit 的 struct MKCooperativeRegion

php - 将 php 和 mysql 与 jquery bMap 一起使用

firebase - 如何在不先创建索引的情况下查询变量字段并应用排序?

java - 使用Firebase身份验证但需要提高安全性

c# - Javascript 不警告 C# 代码中的字符串变量值?

javascript - Mediaelement.js 在 IE 上倒回后隐藏控件

javascript - 在 HTML 中使用 token 时 CSRF 保护的意义是什么

java - map 对象上的 NullPointerException

java - 在 Firebase java 中同步验证 IdToken