AWS S3 存储桶 CORS 错误

AWS S3 存储桶 CORS 错误

我有一个名为 的 Amazon S3 存储桶cs-ia
这是我的 CORS 配置:

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "PUT",
            "POST",
            "GET",
            "HEAD"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [
            "Access-Control-Allow-Origin"
        ]
    }
]

这是存储桶策略:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicListGet",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:List*",
                "s3:Get*"
            ],
            "Resource": [
                "arn:aws:s3:::cs-ia",
                "arn:aws:s3:::cs-ia/*"
            ]
        }
    ]
}

我正在尝试从网页上传图片。我调用createPresignedPost后端,然后发送带有https://s3.amazonaws.com/cs-ia所需负载的 POST 请求。

我收到以下 CORS 错误:

Access to XMLHttpRequest at 'https://s3.amazonaws.com/cs-ia' from origin 'http://192.168.43.52:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

为什么尽管我进行了配置,它仍然不起作用?

相关内容