从S3下载图像会导致随机CORS问题

时间:2019-11-06 13:55:36

标签: javascript amazon-web-services amazon-s3 cors axios

我们正在使用客户端Axios从s3存储桶下载图像。在某些情况下(非常随机,不可重现),发生了CORS问题,错误为400。这仅在Chrome中发生。请提供在哪里寻找问题的建议。

Axios代码:

axios.get("https://storage.s3.eu-central-1.amazonaws.com/some-directory/sdjonfskjdnf/sdkjfnskjnf/IMG-20190012-WA0001.jpeg", {
    responseType: "arraybuffer",
    mode: 'no-cors',
    withCredentials: false,
    headers: {"Access-Control-Allow-Origin": "*"},
})

S3 cors配置:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedMethod>HEAD</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>

0 个答案:

没有答案