I am hosting a react js web app on an aws s3 bucket. My server is a node / express server hosted on an elastic beanstalk environment. I am getting the following CORS error:
...has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource
I went to my s3 bucket and put the following json configuration into the CORS policy:
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"POST",
"HEAD"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": []
}
]
I found that I needed to add "HEAD" in the "AllowedMethods" from another Stack Overflow post (it is not in the AWS documentation). However, I continue to get this error. What am I doing wrong? Is my problem with the above json configuration, or with something else? Incase it is important, my fetch request in my React js app is requesting a hosted zone record which I have stored in Route 53 (this is to work out the ssl certificate) which routes to my EB url...the react app does NOT fetch directly from the EB url itself. Please help, I've been stuck on this error for many hours and cannot find a solution that will work!!!