2016-04-21 114 views
-1

我正在使用服务作品预取Google Maps Javascript SDK。由于服务人员用fetch我不断收到此错误 -跨域请求获取Google Maps SDK

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. 

如何启用谷歌地图SDK CORS?

UPDATE

我使用sw-toolbox,在我的服务人员,我有以下的代码 -

import toolbox from 'sw-toolbox' 
     toolbox.precache([ 
     '/', 
     '/bundle.js', 
     '/manifest.json', 
     '/ola_icon.png', 
     '/favicon.png', 
     'https://maps.googleapis.com/maps/api/js?key=myapikey&callback=initMap' 
     ]) 
+0

你能告诉我们你的代码吗? – Marco

回答

0

有有关访问使用CORS谷歌API的一些文档here