【发布时间】:2021-06-30 05:35:22
【问题描述】:
我有一个存储在 Google Cloud Storage 中的公开可用文件,并且在使用 fetch 从 SPA 检索资源时遇到问题。假设存储桶名称为 pub-bucket,完整资源 URL 为 https://storage.googleapis.com/pub-bucket/v1/example.mid。我已经为存储桶使用以下 JSON 配置启用了 CORS
[
{
"origin": ["*"],
"method": ["GET"]
}
]
但我仍然收到相同的 CORS 错误 Access to fetch at 'https://storage.googleapis.com/pub-bucket/v1/example.mid' from origin 'http://localhost:3001' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. 我不确定是否配置错误,因为以前我使用具有相同 CORS 配置的 DO Spaces 并且从未见过此问题。我还尝试使用this 答案中提到的更多选项扩展我的 CORS 配置,但没有任何改变。
【问题讨论】:
标签: cors fetch google-cloud-storage