I have a project based on a template using Serverless Framework to deploy a react app served from an S3 bucket. The serverless deploy works fine, creates the CloudFormation stack, creates the S3 bucket to distribute the files, but when I load the app, it throws CORS errors, even though everything seems to be fine.
Here’s the error:
Note the request URL and the Referer values.
Here’s the CORS definition for the bucket (as created by the Serverless Framework) in the request URL:
Allowed origin matches the referer value in the request.
Not sure what I should be checking next. “Block Public Access” is disabled on that bucket, as were ACLs at first. I have since enabled ACLS and set Object Ownership to Bucket Owner Preferred.
2
From the comment, the problem was not CORS but the access denied. Thanks for the troubleshooting tips. I added a basic policy and now it’s working (and yes, the bocket uuid has changed, as I had cleaned out the old buckets and rebuilt out of desperation 🙂 ).
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::[THIS-BUCKET]-qxwuykeqwwgz/*"
}
]
}