Reputation: 310
I am designing a geo-location based application and facing the next issues:
Having the location of the user at the moment I simply need to send request to google Places API to get the related establishments using:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=30.26989954982109,-97.73595370200533&radius=100&types=bar&key=myAPIKey
I hate to admit, but it is my first time I face the Cross-Origin-Resource-Sharing and most of the things that are published here regarding CORS don't make sense to me, also the documentation for the API is not very helpful to me since it lacks examples. I would greatly appreciate if anyone could give a descend step-by step explanation how to send requests across domains to retrieve JSON.
Upvotes: 3
Views: 917
Reputation: 7170
At the time of this writing Google Places API does not seem to support CORS. A work around is to enable proxy in your web server. For example, in ngnix, create a new location:
location /maps/ {
proxy_pass https://maps.googleapis.com/maps/;
}
Then, instead of sending an XmlHttpRequest to Google API, send it to your own web server.
Upvotes: 2