Correct S3 Cloudfront CORS Configuration

0 votes

My application stores images on S3 and then proxies them through Cloudfront. I'm excited to use the new S3 CORS support so that I can use HTML5 canvas methods (which have a cross-origin policy) but can't seem to configure my S3 and Cloudfront correctly. Still running into "Uncaught Error: SECURITY_ERR: DOM Exception 18" when I try to convert an image to a canvas element.

Is there something I'm missing here?

UPDATE : Just tried changing the headers to

<AllowedHeader>Content-*</AllowedHeader>
<AllowedHeader>Host</AllowedHeader>

based on this question Amazon S3 CORS (Cross-Origin Resource Sharing) and Firefox cross-domain font loading

Still no go.

UPDATE: MORE INFO ON REQUEST

Request
URL:https://d1r5nr1emc2xy5.cloudfront.net/uploaded/BAhbBlsHOgZmSSImMjAxMi8wOS8xMC8xOC81NC80Mi85NC9ncmFzczMuanBnBjoGRVQ/32c0cee8
Request Method:GET
Status Code:200 OK (from cache)

UPDATE

I think maybe my request wasn't correct, so I tried enabling CORS with

img.crossOrigin = '';

but then the image doesn't load and I get the error: Cross-origin image load denied by Cross-Origin Resource Sharing policy.

amazon-s3corsamazon-cloudfrontIs there something I'm missing here?

UPDATE : Just tried changing the headers to

<AllowedHeader>Content-*</AllowedHeader>
<AllowedHeader>Host</AllowedHeader>

based on this question Amazon S3 CORS (Cross-Origin Resource Sharing) and Firefox cross-domain font loading

Still no go.

UPDATE: MORE INFO ON REQUEST

Request
URL:https://d1r5nr1emc2xy5.cloudfront.net/uploaded/BAhbBlsHOgZmSSImMjAxMi8wOS8xMC8xOC81NC80Mi85NC9ncmFzczMuanBnBjoGRVQ/32c0cee8
Request Method:GET
Status Code:200 OK (from cache)

UPDATE

I think maybe my request wasn't correct, so I tried enabling CORS with

img.crossOrigin = '';

but then the image doesn't load and I get the error: Cross-origin image load denied by Cross-Origin Resource Sharing policy.

Mar 22, 2022 in Others by Edureka
• 13,670 points
1,838 views

1 answer to this question.

0 votes

Create a CORS configuration for your S3 bucket, which should include the following:

<AllowedOrigin>*</AllowedOrigin>

This origin's behaviors can be found under CloudFront -> Distribution -> Behaviors.

HTTP Methods Accepted: +OPTIONS
HTTP Methods Saved in Cache +OPTIONS
Using Request Headers to Cache: The Origin header should be added to your whitelist.
Wait for CloudFront to propagate the new rule, which should take about 20 minutes.

Distinct answers (with valid CORS headers) should now be cached for different client Origin headers in your CloudFront distribution.

If you need to know more about Cloud Computing, We recommend joining Cloud Computing Certification today.

answered Mar 24, 2022 by Edureka
• 13,670 points

Related Questions In Others

+1 vote
0 answers
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
509 views
0 votes
1 answer
0 votes
1 answer

Git error: "Please make sure you have the correct access rights and the repository exists"

Your git URL might have changed. Change ...READ MORE

answered Feb 17, 2022 in Others by Aditya
• 7,680 points
9,642 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to add S3 BucketPolicy with AWS CDK?

In AWS CDK, there are two ways ...READ MORE

answered Mar 9, 2022 in Others by gaurav
• 23,260 points
2,714 views
0 votes
1 answer

how do i to forward domain.com to www.domain.com at godaddy for s3 hosted site?

Go to GoDaddy.com and enter your username ...READ MORE

answered Mar 10, 2022 in Others by gaurav
• 23,260 points
438 views
0 votes
1 answer

What does it mean when owner is None on an AWS S3 object?

S3 Object Ownership is an Amazon S3 ...READ MORE

answered Mar 15, 2022 in Others by gaurav
• 23,260 points
1,146 views
0 votes
1 answer

How can I restrict access to an S3 website to Cloudfront?

Make a CloudFront access identity for origin ...READ MORE

answered Mar 24, 2022 in Others by Edureka
• 13,670 points
2,090 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP