S3 CORS not working with jQuery Ajax request in Chrome

I have the following S3 bucket: http://my-bucket.s3-website-eu-west-1.amazonaws.com/

I added the CORS configuration, according to http://docs.amazonwebservices.com/AmazonS3/latest/dev/cors.html :

<CORSConfiguration>
 <CORSRule>
<AllowedHeader>x-requested-with</AllowedHeader>
 <AllowedHeader>*</AllowedHeader>
   <AllowedOrigin>*</AllowedOrigin>
   <AllowedMethod>POST</AllowedMethod>
    </CORSRule>
 <CORSRule>
   <AllowedOrigin>http://*.test.com</AllowedOrigin>
   <AllowedMethod>POST</AllowedMethod>
 </CORSRule>
</CORSConfiguration>

I am making an AJAX Post request in my bucket using jquery (note, origin is jd.test.com:8000):

$.ajax('http://my-bucket.s3-website-eu-west-1.amazonaws.com/', {
    type: "POST",
    data: $(":hidden", self).serializeArray(),
    files: $(":file", self),
    statusCode: {
      204: function(){
        //do something
      }
    }
});

After completing the request, my chrome console complains:

XMLHttpRequest cannot load http://my-bucket.s3-website-eu-west-1.amazonaws.com/. Origin http://www.jd.test.com:8000 is not allowed by Access-Control-Allow-Origin.

Any help regarding why the POST request is not being executed will be appreciated.

Thank!

+5
source share
4 answers
+2
+2

. AllowedMethod PUT? PUT not POST.

-

. 403 PUT. POST 400.

+1

, AllowedHeader * CORS S3.

CORS S3:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <CORSRule>
        <AllowedOrigin>*</AllowedOrigin>
        <AllowedMethod>POST</AllowedMethod>
        <MaxAgeSeconds>3000</MaxAgeSeconds>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
</CORSConfiguration>
+1

All Articles