S3 Cross-Origin Resource Sharing Not working
amazon-s3, cors, ruby-on-rails
Solution
I have a suspicion that you're not using the correct S3 endpoint address format that's required for CORS support.
i.e. S3 buckets support both of these formats:
- `http://bucket.s3.amazonaws.com/object`
- `http://s3.amazonaws.com/bucket/object`
But only the first URL will work with CORS according to the documentation:
with CORS, you can configure your bucket to explicitly enable cross-origin requests from website.s3-website-us-east-1.amazonaws.com.
Problem
I'm trying to use blur.js to blur user uploaded images, and I'm storing the images on Amazon S3. I've set up what I think to be the correct CORS configuration, but the images can't be blurred and I get this error in the browser: ``` Unable to get image data from canvas because the canvas has been tainted by cross-origin data. ``` Here's my CORS configuration: ``` <?xml version="1.0" encoding="UTF-8"?> <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <CORSRule> <AllowedOrigin>*</AllowedOrigin> <AllowedMethod>GET</AllowedMethod> <AllowedMethod>POST</AllowedMethod> <AllowedHeader>*</AllowedHeader> </CORSRule> </CORSConfiguration> ``` Any idea what's wrong?