google-chrome - 使用 Google Cloud Storage 的 Google Chrome 中的范围请求出现 CORS 错误

标签 google-chrome cors google-cloud-storage http-range

我收到一个错误,但无法找到修复方法。我正在从 Google Cloud Storage 发送 CORS 资源的获取,但是当我发送但不包含范围请求时,它会起作用。但如果我添加范围请求,它就会失败。可能会出现什么问题?

fetch("https://storage.googleapis.com/bucket/abc.pdf", {
  "headers": {
    "range": "bytes=24772608-24832146"
  },
  "referrer": "http://localhost:8000/",
  "referrerPolicy": "strict-origin-when-cross-origin",
  "body": null,
  "method": "GET",
  "mode": "cors",
  "credentials": "omit"
});

请注意导致问题的 header 范围。

这是我的 Google 存储 CORS 配置:

[{"origin": ["*"],"responseHeader": ["Content-Type", "Accept-Ranges", "Content-Range", "Content-Encoding", "Content-Length","Access-Control-Allow-Origin"],"method": ["GET", "HEAD", "OPTIONS"],"maxAgeSeconds": 3600}]

Google Cloud Storage 支持范围请求,但不清楚如何配置它。

最佳答案

原来我缺少 CORS JSON 中的范围。这么简单的问题,希望 Google 能给出更好的文档。

[{"origin": ["*"],"responseHeader": ["Content-Type", "Accept-Ranges", "Content-Range", "Content-Encoding", "Content-Length","Access-Control-Allow-Origin","Access-Control-Allow-Methods","Range"],"method": ["GET", "HEAD", "OPTIONS"],"maxAgeSeconds": 3600}]

关于google-chrome - 使用 Google Cloud Storage 的 Google Chrome 中的范围请求出现 CORS 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65246709/

相关文章:

javascript - 延迟后如何在 window.onload 中加载 javascript 函数

google-chrome - 来自所有已登录设备的浏览器历史记录未进入 chrome 扩展程序

java - chrome 不允许 localhost 来源

python - 如何使用 Dataproc 中的 Jupyter notebook 获取 GCS Bucket 中的文件列表?

google-app-engine - 在 "unexpected error"中使用 google cloud 添加计费方式

google-chrome - 使用chromedp加载现有的Chrome用户配置文件和数据

javascript - 尝试使用 AngularJS 将图像上传到 Cloudinary 时,Access-Control-Allow-Origin 不允许 Origin http ://localhost. com:8000

javascript - 如何添加模式: 'no-cors' to XMLHttpRequest?

javascript - 在 CouchDB 中摆脱 CORS?

Python 创建 Google 存储桶