CORS issue for OPTIONS method in Cloudfront Distribution + S3 Origin

0

Hi,

We are facing an CORS issue for OPTIONS method in CloudFront Distribution with origin to S3 bucket.

I have configured below settings in the Distribution.

-Allowed OPTIONS method. -Used 'CORS-S3Origin' policy in Origin request policy. -Used 'CORS-With-Preflight' policy in Response headers policy.

We have also added a below CORS configuration in S3 bucket as well.

[ { "AllowedHeaders": [ "" ], "AllowedMethods": [ "GET", "HEAD" ], "AllowedOrigins": [ "" ], "ExposeHeaders": [] } ]

But still we are not getting OPTIONS method in a "access-control-allow-methods:" response header we are getting GET and HEAD methods in response.

We also tried with multiple Cloudfront functions as well but did not succeeded and received 403, 502, or function validations errors.

Can you please help us? here only we need to achieve that CORS should allow for wildcard origin for OPTIONS method along with GET and HEAD.

Thanks, Girish

Girish
질문됨 9달 전554회 조회
1개 답변
0

For S3, AllowedMethod element are:

GET
PUT
POST
DELETE
HEAD

[S3 allows OPTIONS request by default]https://docs.aws.amazon.com/AmazonS3/latest/API/RESTOPTIONSobject.html) and CloudFront allows OPTIONS request if you enabled it in behavior setting.

So, your application does not need to evaluate a CORS response like "Access-Control-Allow-Methods: POST, GET, OPTIONS" defined in MDN CORS document to check if S3 or CloudFront supports OPTIONS method.

답변함 9달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인