I've created a REST API that API Gateway will route to. Using Postman I can do a POST request to my API Gateway and everything works fine. I have a static Angular site hosted on S3 that has CloudFront in front of it. When trying to make that same POST request from Cloudfront to S3 I get the following:
Access to XMLHttpRequest at 'API Gateway URL' from origin 'Cloud Front URL' has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.
I've enabled CORS in my API Gateway, I've added Whitelisting for ORIGIN in my Cloudfront. I've added CORS to my S3. I'm banging my head here trying to figure out where I'm going wrong.
S3 CORS Rules:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<MaxAgeSeconds>300</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Thank you for any help.
access-control-allow-origin
, which does not make sense -- that is a response header, not a request header, and should not be sent with a request (nor proposed in pre-flight). Showing the front-end code that actually makes thePOST
request seems appropriate, here. – Michael - sqlbot