I needed to change my AWS S3 bucket CORS policy to enable the upload of files for my ReactJS to AWS S3, but I keep getting this API response:
Expected params
I'm not sure if this helps. I ran into this same problem recently and it seems like AWS made some changes with how we define our CORS configurations. For example, if you want to allow certain Methods on your S3 bucket in the past you have to do something like this on the editor:
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
The config below is equivalent to the one on the top but takes the form of an array.
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"PUT",
"POST",
"HEAD",
"DELETE"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": [],
"MaxAgeSeconds": 3000
}
]
Let me know if this helps. Thank you!
We encountered the same error. We needed two fixes. (Not sure if this is helpful in your case):
To configure CORS for your static website the CORS object has to be in JSON format see aws docs cors configuration. To specify the actions allowed on that bucket you want to enable CORS on, you must define a set of CORS Rules. The CORS Rules is an array that holds a set of objects where each object corresponds to a particular rule. To learn more about how to define CORS Rules see aws cors rule. The error you are receiving is due the fact that your CORS Rule is in improper format. If you follow the above example by @FaitAccompli the error should be resolved.