Amazon AWS S3 Error: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

I am trying to upload files from my browser app to s3 but I get the following error when uploading:

copyNo 'Access-Control-Allow-Origin' header is present on the requested resource.

Need to configure your CORS Settings for your bucket on amazon s3 console.

To edit your S3 bucket permissions:

  1. Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/

  2. In the Buckets list, open the bucket whose properties you want to view and click “add CORS configuration”

  3. Write the rules you are willing to add in between the tags <CORSConfiguration>

copy<CORSConfiguration>
  <CORSRule>
    <AllowedOrigin><http://www.yourdomain.com></AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <AllowedHeader>*</AllowedHeader>
  </CORSRule>
</CORSConfiguration>

You can learn more about rules at: http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html

https://docs.aws.amazon.com/AmazonS3/latest/userguide/cors-troubleshooting.html