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
demandé il y a 9 mois551 vues
1 réponse
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.

répondu il y a 9 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions