CORS 策略已阻止从来源 'http://localhost:4200' 访问位于 'https://maps.googleapis.com/maps/api/place/details' 的 XMLHttpRequest:

Access to XMLHttpRequest at 'https://maps.googleapis.com/maps/api/place/details' from origin 'http://localhost:4200' has been blocked by CORS policy:

我正在尝试呼叫 google 个地方 api 以便我可以获得有关某个位置的一些详细信息,但我想我不允许在本地主机上使用..

我应该怎么做才能访问 api?

我尝试在我的 api 密钥上的 http referrers 添加 localhost,但没有解决。

This is how i make the get call

Here i call that function, after i get the place_id from google places autocomplete input

This is the error i get

我通过允许 CORS 扩展来修复它(允许 CORS:Access-Control-Allow-Origin)。

https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf?hl=en

另一种选择是通过代理,但扩展修复它的速度更快。