I'm trying to do a get request from my localhost machine(And my app will stay on localhost) to get some information about a place.
However, the Google Places API and/or my Chrome won't let me do this request due to CORS (XMLHttpRequest cannot load https://maps.googleapis.com/maps/api/place/details/json?placeid=[placeid]&key=[key]. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
).
Is there some way (Without a CORS Chrome plugin) to get access from the Google Places API?
I'm just using a simple GET request in Javascript with Vue2 & Vue Resource:
this.$http.get(`https://maps.googleapis.com/maps/api/place/details/json?placeid=${googleplacesPlace}&key=${googleplacesToken}`).then(response => {
})
Ref on
Using the Google Maps API with Vue.js
Maps JavaScript API, Hello World
Same issue for me, solved it with the Google Maps Javascript API this way :Instead of using the direct api url with does not accept CORS, use instene of google map (new google.maps.places...)
you can use this to bypass cors.