Fausto95/aws-s3

Access has been blocked by CORS policy.

Closed this issue ยท 3 comments

Whenever I try to upload an image in my s3 bucket I am getting the following error

Access to fetch at 'https://lab-profile-images.s3.amazonaws.com/' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I am using the react-s3 library. In my s3 configuration I'm passing

  • bucketName
  • region
  • accessKeyId
  • secretAccessKey
  • successActionStatus

I have not passed the dirName. Is it compulsory to pass dirName? Because in the documentation of react-s3 here, they have mentioned dirName as Optional in the file upload example.

I have also tried to disable chrome web security and tried to upload but still no luck. The CORS access is enable on server side.
Anyone can guide me ?

Screenshot 2020-07-24 at 16 48 00

Screenshot 2020-07-24 at 16 48 00

go to your s3 bucket, inside permissions section click on CORS configuration tab and make some changes on CORS rules like:-

<AllowedHeader>*</AllowedHeader>

@mdnmnahmed Thanks!!

@user09876090 my pleasure...๐Ÿ˜Š