https://accounts.google.com/gsi/client 缺少“Access-Control-Allow-Origin”标头

问题描述 投票:0回答:1

总结

作为学习使用 Google Auth 的一部分,我发现 fetch("https://accounts.google.com/gsi/client") 会导致

Access to script at 'https://accounts.google.com/gsi/client' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

预期行为

标头应包含 access-control-allow-origin: * 就像获取时一样 https://apis.google.com/js/api.js

实际行为

响应标头不包含 Access-Control-Allow-Origin 标头

重现步骤

在 devtools 的控制台或脚本中运行 fetch("https://accounts.google.com/gsi/client")

authorization google-oauth
1个回答
0
投票

我发现我为

crossorigin="anonymous"
标签设置了
script

所以,如果我不使用 CORS,一切都会正常。

© www.soinside.com 2019 - 2024. All rights reserved.