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
gefragt vor 2 Jahren163 Aufrufe
Keine Antworten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen