0

Here is my S3 Cors file:

<?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>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>

I cannot put Options for an allowed method. I tried also with Cloudfront, but no luck.

This is my conf in Cloudfront: Cloudfront settings

Is there any simple way to give 200 for all Option methods in S3?

user666
  • 834
  • 2
  • 10
  • 20
  • Possible side note: be sure you set the CloudFront Error Caching TTLs to 0 while troubleshooting, otherwise you may have things set correctly but not realize it, because you are receiving a cached error response. By default, to prevent repeated invalid requests from being sent unnecessarily sent to the origin server, CloudFront caches error responses for reuse if the same request is made again within 5 minutes. See [Amazon CloudFront Latency](https://stackoverflow.com/a/35541525/1695906) for an explanation and steps to set these timers to 0. – Michael - sqlbot Nov 04 '17 at 19:26
  • @Michael-sqlbot: Update: I'm actually using an ElastiBeanstalk endpoint and not cloudfront. Any ideas to change it from that? – user666 Nov 06 '17 at 15:52

1 Answers1

0

OPTIONS should be supported for AllowedMethod http://docs.aws.amazon.com/cloudfront/latest/APIReference/API_AllowedMethods.html

One of the following response headers:

Access-Control-Allow-Methods
Access-Control-Allow-Headers
Access-Control-Allow-Origin

is required to enable OPTIONS, check your config against this: http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html

Moe
  • 2,672
  • 10
  • 22
  • Thanks for answering. I uploaded an image with my Cloudfront settings. I don't use API Gateway, I use S3 bucket and linked a Cloudfront to it. – user666 Nov 04 '17 at 17:39
  • ahh sorry my bad I've been working with API Gateway all day and when I saw CORS in your post that's all I could see haha. I'm not sure if you've seen this already but I'll post it just in case: Amazon has published a doc on how to troubleshoot CORS http://docs.aws.amazon.com/AmazonS3/latest/dev/cors-troubleshooting.html – Moe Nov 04 '17 at 17:47
  • Update: I'm actually using an ElastiBeanstalk endpoint and not cloudfront. Any ideas to change it from that? – user666 Nov 06 '17 at 15:53