この質問は複数の人から聞いたことがありますが、答えはどれも私のために働いていません。Google Maps API:要求されたリソースに「Access-Control-Allow-Origin」ヘッダーがありません
私はreact/axiosでgoogle maps apiにAPI呼び出しをしようとしています。私は皆のポイントへ https://www.html5rocks.com/en/tutorials/cors/
が、記事のコンCORSを読んだ
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.
:
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);
});
}
これはエラーMSGがある:
は、これは私のGETリクエストであります私はそこに私の問題に対する答えを見つけることができません。