aws-sdk javascript s3 managedUpload CORS error caused by CacheControl Option

0

If I upload this with the CacheControl option, upload works fine. But when I load it on the client side I get a CORS error. If I remove CachControl, obviously the CORS error doesn't come up. My Bucket has CORS-Policy like this

My Upload code is following like

import { FileUpload } from "../types/scalars/Upload.scalar";

 new S3.ManagedUpload({
        params: {
            ACL: "public-read",
            Bucket: process.env.AWS_BUCKETNAME || "",
            Body: upload.createReadStream(),
            Key: filename || upload.filename,
            CacheControl: "max-age=604800,public,immutable",
        },
        // tags,
    }).promise();

My S3 CORS Policy is following like

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET",
            "POST"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": []
    }
]
Jihoon
asked 2 years ago162 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions