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

Some time you got the error when try to access the file from AWS S3, It’s say No ‘Access-Control-Allow-Origin’ header is present on the requested resource. No need to worry, Follow the below steps to fixed.
You just need to configure your CORS Settings for your bucket on amazon s3 console.
-
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/
-
In the Buckets list, click on the bucket whose properties you want to Edit.
-
Click on Permissions Tab. and then click on CORS configuration Tab
-
Write the rules you are willing to add in between the tags <CORSConfiguration>
Copy The below code : (S3 bucket permissions CORS configuration for ‘Access-Control-Allow-Origin’)
1 2 3 4 5 6 7 8 9 |
<?xml version="1.0" encoding="UTF-8"?> <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <CORSRule> <AllowedOrigin>*</AllowedOrigin> <AllowedMethod>GET</AllowedMethod> <MaxAgeSeconds>3000</MaxAgeSeconds> <AllowedHeader>*</AllowedHeader> </CORSRule> </CORSConfiguration> |
What is Cross-Origin Resource Sharing (CORS)
Cross-origin resource sharing (CORS) defines a way for client web applications that are loaded in one domain to interact with resources in a different domain. With CORS support, you can build rich client-side web applications.
You can learn more about rules at: http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html