简体   繁体   English

如何在云对象存储CORS PUT请求中设置Access-Control-Allow-Credentials标头

[英]How to set Access-Control-Allow-Credentials header in cloud-object-storage CORS PUT request

I have an image in IBM Cloud Object store, it requires authorisation for fetching. 我在IBM Cloud Object存储中有一个映像,它需要授权才能进行提取。 But this does not work in browser and iOS( I'm building a hybrid app) but works fine in Android. 但这在浏览器和iOS(我正在构建一个混合应用)中不起作用,但在Android中可以正常工作。 Debugging I see Pre-flight request failing with 403 Authorised error. 调试我看到飞行前请求失败,并显示403授权错误。 In Andorid there is not preflight request so image loads fine but browser and iOS's webview make a preflight request. 在Andorid中,没有预检请求,因此图像加载正常,但浏览器和iOS的Webview发出了预检请求。

I need to setup the backend CORS in such a way it allows Authorisation Header and OPTIONS header. 我需要以允许Authorization Header和OPTIONS标头的方式设置后端CORS。

I found this on how to do it, and have setup the Headers and Methods but I can't find out the syntax for setting the Allow-Credentails. 我发现对如何做到这一点,并且已经设置了页眉和方法,但我不能找出设置允许-Credentails的语法。

This is my current PUT request body for setting CORS: 这是我当前用于设置CORS的PUT请求正文:

<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
<AllowCredentials>true</AllowCredentials>
</CORSRule>
</CORSConfiguration>

This fails with MalformedXML. MalformedXML失败。 But if I remove the AllowCredentials it works fine. 但是,如果我删除AllowCredentials,它可以正常工作。

So first question is what's the XML syntax for AllowCredentials. 因此,第一个问题是AllowCredentials的XML语法是什么。

The Access-Control-Allow-Credentials header was not needed. 不需要Access-Control-Allow-Credentials标头。 The 403 error with the OPTIONS request went away once i set the CORS as this: 我将CORS设置为以下方式后,OPTIONS请求的403错误就消失了:

<CORSConfiguration>
    <CORSRule>
        <AllowedMethod>PUT</AllowedMethod>
        <AllowedMethod>POST</AllowedMethod>
        <AllowedMethod>DELETE</AllowedMethod>
        <AllowedMethod>GET</AllowedMethod>
        <AllowedOrigin>*</AllowedOrigin>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
</CORSConfiguration>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 withCredentials 时被 cors 拒绝,设置了访问控制允许凭据和来源 - rejected by cors when using withCredentials, despiete access-control-allow-credentials and origin are set 现有解决方案不起作用 - (AWS Lambda Api) 响应中“Access-Control-Allow-Credentials”header 的值为“”,必须为“true” - Existing solutions not working- (AWS Lambda Api) The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' CORS 策略:请求 header 字段 access-control-allow-origin 在预检响应中被 Access-Control-Allow-Headers 不允许 - CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response Javascript CORS 请求,不存在带有 200 状态代码的“Access-Control-Allow-Origin”标头 - Javascript CORS request, No 'Access-Control-Allow-Origin' header is present with 200 status code 如何使用Ruby SDK在AWS S3对象上设置Access-Control-Allow-Origin标头? - How to set the Access-Control-Allow-Origin header on an AWS S3 object using Ruby SDK? API Gateway CORS:没有“Access-Control-Allow-Origin”标头 - API Gateway CORS: no 'Access-Control-Allow-Origin' header AWS 对 XMLHttpRequest 的访问已被 CORS 策略阻止:No 'Access-Control-Allow-Origin' header - AWS Access to XMLHttpRequest at from origin has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header 如何根据允许的来源列表设置 Access-Control-Allow-Origin 标头的值? - How to set the value of the Access-Control-Allow-Origin header based on a list of allowed origins? “缺少CORS标头&#39;Access-Control-Allow-Origin&#39;”:调用部署的AWS Api网关时 - “CORS header ‘Access-Control-Allow-Origin’ missing ” : while calling deployed AWS Api gateway Amazon S3奇怪的CORS行为:所请求的资源上不存在“ Access-Control-Allow-Origin”标头 - Amazon S3 weird CORS behaviour: No 'Access-Control-Allow-Origin' header is present on the requested resource
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM