In this tutorial, we will learn how we can resolve the CORS issue for the amazon s3 object link. This is typically the configuration setup on the s3 bucket.
Cross origin resources sharing is the way to trust between the two web services. So if the two web services don't satisfy then a CORS issue may arise.
Cors is a mechanism for the web application that controls to listen to certain request from other web applications which is not hosted on the same server. It will not grant access to the content from other applications. So, in order to interact between two different web applications, we need to enable the Cors for that particular app.
Hence, we need to enable the CORS in the amazon s3 bucket to get access to the content inside it.
To enable CORS policy in amazon s3, follow the following steps.
Login in to your amazon management console and go to the services and select s3
Now click on the bucket name listed inside s3 where you want to configure the CORS policy
You can see the different tabs as shown below, so click on the Permissions.
Scroll down to the bottom, we can see the Cross-origin resource sharing (CORS) option. Now click on the Edit button to add the policy. After that add the following JSON configuration
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": [
"Content-Range",
"Content-Length",
"ETag"
],
"MaxAgeSeconds": 3000
}
]
Click on save changes. For more advanced configuration please visit the s3 CORS config.