Adding on @Vikas's answer, you can implement more granular control in your S3 bucket CORS policy like this:
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"POST",
"GET",
"PUT"
],
"AllowedOrigins": [
"https://*.example.com",
"http://localhost:*",
"https://*.test.example.com"
],
"ExposeHeaders": [
"ETag",
"Content-Length",
"Content-Type"
],
"MaxAgeSeconds": 3600
}
]