Report this

What is the reason for this report?

CORS issue with presigned URL once I add ACL: 'PublicRead'

Posted on July 28, 2022

Hello,

So I’m trying to upload to Spaces using the AWS s3 presigned URL SDK, but I’m getting a CORS error whenever I set the ACL to public read.

// generates URL without "x-amz-acl=public-read"
// does not throw CORS error, but uploads a private file that blocks public access

const s3Params = {
    Bucket: process.env.UploadBucket,
    Key,
    Expires: URL_EXPIRATION_SECONDS,
    ContentType: decodeURIComponent(mimeType)
  }
  const uploadURL = await s3.getSignedUrlPromise('putObject', s3Params)


// generates URL with "x-amz-acl=public-read" query string parameter
// throws CORS error when I try to PUT an object there

const s3Params = {
    Bucket: process.env.UploadBucket,
    Key,
    Expires: URL_EXPIRATION_SECONDS,
    ContentType: decodeURIComponent(mimeType),
    ACL: 'public-read'
  }
  const uploadURL = await s3.getSignedUrlPromise('putObject', s3Params)

In my spaces config, I have Allowed Headers set to “*”, so I’m not sure what is causing the CORS error. Any ideas?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.