Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Cordova 5.0.0 Google Maps with Content Security Policy

I m building Cordova Application for Android using Cordova 5.0.0. and I m using Google Maps without Plugin and it must be without plugin. I include this script and meta tag .also Cordova using whitelist plugin.

  <!-- Meta tag -->
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
  
   <!-- Google Maps-->
 <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>

it's give me this error:

 Refused to load the script 'https://maps.googleapis.com/maps/api/js?sensor=true' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval'".
like image 243
Nazır Dogan Avatar asked Jun 26 '15 12:06

Nazır Dogan


1 Answers

Try the using the following content-security-policy:

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

Google maps needs the rules defined for script-src as above with 'unsafe-inline' 'unsafe-eval'. ; )

like image 194
Italo Maia Avatar answered Sep 28 '22 06:09

Italo Maia