gpt4 book ai didi

cors - Google Cloud Storage签名URL的预检未返回CORS响应 header

转载 作者:行者123 更新时间:2023-12-04 21:03:26 25 4
gpt4 key购买 nike

我正在尝试执行签名的resumable upload to GCS。我们的前端遇到了针对初始请求的CORS限制:Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
响应 header 不显示任何CORS header :
alt-svc: quic=":443"; ma=2592000; v="44,43,39,35"
cache-control: private, max-age=0
content-length: 0
content-type: text/html; charset=UTF-8
date: Tue, 13 Nov 2018 20:28:32 GMT
expires: Tue, 13 Nov 2018 20:28:32 GMT
server: UploadServer
status: 200
x-guploader-uploadid: AEnB2Ups1tKbTbhPmsjrPXbIuIUyQt135AlSJ1n7-7XTwMrtQ2vUvn1WwpX3a_iusfmsXHaufdf5B3H2PzmDONs2wW7tKkLarYoxrVyWalhaX6FzGQPoRW0

调试时,我发送了一个curl请求来模仿我们前端的请求:
curl -H "Access-Control-Request-Headers: content-type,x-goog-resumable" \
-H "Access-Control-Request-Method: POST" \
-H "Origin: https://www.example.com" \
-X OPTIONS -I https://storage.googleapis.com/bucket/...

同样,该响应不包含任何CORS响应 header :
HTTP/2 200
x-guploader-uploadid: AEnB2UqwKiRSJjHjF9mzsZRMODdQmF6xhUAhdeEenuD0_WXmxpVA6n0i_HWY2NOJxvXS2t_I4IoFW_yvz6lssMz_HVmvlswL5NilGC3wE2YT0-L9aD7Pf1Q
date: Tue, 13 Nov 2018 21:39:53 GMT
expires: Tue, 13 Nov 2018 21:39:53 GMT
cache-control: private, max-age=0
content-length: 0
server: UploadServer
content-type: text/html; charset=UTF-8
alt-svc: quic=":443"; ma=2592000; v="44,43,39,35"

我已经使用gsutil cors set cors.json gs://bucket设置了我的存储桶CORS设置,其中cors.json包含[{"maxAgeSeconds": 3600, "method": ["GET", "POST", "PUT", "OPTIONS"], "origin": ["*"]}]
我在这里想念什么吗?

最佳答案

我找到了解决方案。我必须将x-goog-resumable添加到响应 header 列表中。

我的CORS文件是

[
{
"origin": ["*"],
"responseHeader": [
"Content-Type",
"Access-Control-Allow-Origin",
"x-goog-resumable"],
"method": ["GET", "HEAD", "DELETE", "POST", "OPTIONS"],
"maxAgeSeconds": 3600
}
]

至少飞行前开始工作

关于cors - Google Cloud Storage签名URL的预检未返回CORS响应 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53290008/

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