How to enable CORS for Google Places API
Asked Answered
V

1

7

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?

Violist answered 11/5, 2015 at 22:1 Comment(1)
Use the Javascript API and Places Service to access the Places API from the frontend.Howie
M
-1

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

Please read the following to get started: Link1, Link2

Mote answered 12/5, 2015 at 21:3 Comment(2)
Which is useless if you need POST requestPeculiarize
JSONP is unsafe and I believe it's even blocked by Google API, it's not recommended. Use google api client library insteadAsher

© 2022 - 2024 — McMap. All rights reserved.