【发布时间】:2018-11-05 08:10:59
【问题描述】:
<iframe width="100%" height="427" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?q=place_id:[place_id]&key=[my_key]" allowfullscreen></iframe>
“Google Maps Platform 拒绝了您的请求。此 IP、站点或移动应用程序无权使用此 API 密钥。从 IP 地址 xxx.xxx.xxx.xxx 收到请求,引用者:https://xxx.xxx/”
在 Google Dev 中,我启用了 Maps Embed API 和 Maps Static API。我已将密钥限制为仅与我的域一起使用,其中包含上述代码,例如https://[asterisk].thedomain.com/[asterisk]。
当我不将密钥限制在这个单一域时,地图嵌入工作并且不会引发错误。
问题是,密钥在代码中是可读的,因此我需要将密钥限制在我的域中。
有什么想法吗?
谢谢。
【问题讨论】:
-
我刚刚发现我遇到了同样的问题,但没有明显的问题原因。我的网站是从“www.domain.com”提供的,所以我的两个“https://*.domain.com/*”和“http://*.domain.com/*”过滤器应该可以工作......但事实并非如此。