Cloudfront return 403 on OPTION request

0

I have a cloudfront distribution pointing to S3.

Accessing to de URL directly works fine.

But is part o a complex API, de API return a 307 that points to the cloudfront, and the webbrowser made and and OPTIONS request.

The OPTIONS return a 403

The distributions contains a single behavior and accepts GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE

I have tested several combinations of CORS response headers but none works. This is my current configuration

current configuration

any idea about why cloudfront returns a 403?

질문됨 2달 전86회 조회
1개 답변
2
수락된 답변

It seems like the OPTIONS request is being blocked either due to incorrect CORS configuration or WAF rules blocking the request. A few things to check:

Verify that the CORS configuration on the S3 bucket allows the Origin, Access-Control-Request-Method and Access-Control-Request-Headers that are being sent in the OPTIONS request.

Check if a WAF web ACL is associated with the CloudFront distribution and blocking the OPTIONS request. The WAF rules need to allow OPTIONS requests to pass through.

Make sure the CloudFront distribution behavior allows OPTIONS method.

Try simplifying the CORS configuration on S3 to just allow all origins, methods and headers as a test:


[
  {
    "AllowedHeaders": ["*"],
    "AllowedMethods": ["GET","PUT","POST","DELETE","HEAD","OPTIONS"], 
    "AllowedOrigins": ["*"],
    "ExposeHeaders": []
  }
]

Check CloudFront and S3 access logs to see exactly what requests are reaching the origin and getting blocked.

profile picture
전문가
답변함 2달 전
profile picture
전문가
검토됨 2달 전
  • I was assuming that cloudfront itself handled the CORS requests, and no setup from S3 side was needed. I solved de problem after configure CORS on S3.

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

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

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

관련 콘텐츠