我正在尝试从我的本地主机计算机执行获取请求(并且我的应用程序将保留在本地主机上)以获取有关某个地点的一些信息。
但是,由于 CORS,Google Places API 和/或我的 Chrome 不允许我执行此请求(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.
).
有没有某种方法(无需 CORS Chrome 插件)可以从 Google Places API 进行访问?
我只是在 Javascript 中使用 Vue2 和 Vue 资源的简单 GET 请求:
this.$http.get(`https://maps.googleapis.com/maps/api/place/details/json?placeid=${googleplacesPlace}&key=${googleplacesToken}`).then(response => {
})
const PROXY_URL = 'https://cors-anywhere.herokuapp.com/';
const TARGET_URL = 'https://maps.googleapis.com/maps/api/place/autocomplete/json?&key=KEY'
const URL = PROXY_URL + TARGET_URL
你可以用它来绕过cors。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)