Rob Smith
Rob Smith

Reputation: 147

XMLHttpRequest cannot load http://xx-xx.s3.amazonaws.com/. Response to preflight request doesn't pass access control check

I am trying to implemet react fineuploader direct upload to s3 bucket.I get this error when i try to upload files.

XMLHttpRequest cannot load http://xx-xx.s3.amazonaws.com/. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://x.x.com' is therefore not allowed access. The response had HTTP status code 403.

In my local i can write to s3 using cors-anywhere if i append it before xx-xx.s3.amazonaws.com

I am using react+node+express and Django as backend.

Upvotes: 0

Views: 352

Answers (2)

Rob Smith
Rob Smith

Reputation: 147

I updated the aws console to allow any domain and saved then i changed it back to just my domain and it worked.

Upvotes: 0

rsp
rsp

Reputation: 111506

If the target server doesn't allow cross-origin requests then you will have to proxy those requests by your own backend, which is a good practice anyway because those requests will likely need to contain some API keys or other credentials that should never be stored on the client-side.

Upvotes: 0

Related Questions