gpt4 book ai didi

javascript - 对地点服务的所有请求都必须使用 https ://protocol, 并包含 API key

转载 作者:行者123 更新时间:2023-12-03 00:22:32 24 4
gpt4 key购买 nike

每当我向 Google 的 Places API 发出 axios GET 请求时,都会收到错误消息:

"has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is 
present on the requested resource."

我检查了 Google Place API 的文档并发现了这一点:

"Each of the services is accessed as an HTTP request, and returns either an JSON or 
XML response. All requests to a Places service must use the https:// protocol, and
include an API key."

我是否正确理解,为了让我使用该 API,请求必须来自具有域名和 SSL 证书的托管网站,以便我可以拥有 https://协议(protocol)?

我目前正在处理http://localhost:8080/#/ 。有没有办法让我使用这个 API,这样我就可以在此时不使用托管来开发我的应用程序?

最佳答案

该文档所说的是

all requests must use https and must include an API key

CORS 的事情表明,

requests must come from a server, not a browser,

这并不意味着服务器必须是 https 服务器,它只需使用 HTTPS 向该 API 发出请求

关于javascript - 对地点服务的所有请求都必须使用 https ://protocol, 并包含 API key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54247570/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com