How to enable CORS for Google Places API

余生颓废 提交于 2019-12-10 02:34:44

问题


I have tried everything possible to make my app work without the need for the "Enable CORS extension for Chrome". I followed the steps on Google's official website which talks of authtokens, tried using every different key, but nothing works. I get the following error:

XMLHttpRequest cannot load https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=MyKey&location=33.854546,-84.35870369999999&types=restaurant&rankby=distance. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin http://localhost:8100 is therefore not allowed access.

Is it even possible to access Google Places API from inside an app, without the CORS extension for Chrome?


回答1:


Instead of CORS, you can use JSONP to accomplish your task.

Please read the following to get started: Link1, Link2



来源:https://stackoverflow.com/questions/30178359/how-to-enable-cors-for-google-places-api

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