为了账号安全,请及时绑定邮箱和手机立即绑定

Google Maps API:请求的资源上没有“ Access-Control-Allow

Google Maps API:请求的资源上没有“ Access-Control-Allow

月关宝盒 2019-10-22 21:58:04
我已经看到这个问题被多个人问到,但没有一个答案对我有用。我正在尝试使用react / axios对Google Maps api进行API调用。这是我的要求:componentDidMount() {  axios({   method : 'get',   url : `http://maps.googleapis.com/maps/api/js?key=${key}/`,   headers: {     "Access-Control-Allow-Origin": '*'     "Access-Control-Allow-Methods": 'GET',   },  }) .then(function (response) {  console.log(response); }) .catch(function (error) {  console.log(error); });}这是错误消息:XMLHttpRequest cannot load http://maps.googleapis.com/maps/api/js?key=xxxxxxxxx/. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.我已经阅读了con CORS文章,其他所有人都指向 https://www.html5rocks.com/en/tutorials/cors/但我在那里找不到解决问题的答案。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 504 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信