0

here is my problem : CORS are set as supposed to be on the S3 :

<CORSConfiguration>
 <CORSRule>
   <AllowedOrigin>*</AllowedOrigin>
   <AllowedMethod>GET</AllowedMethod>
 </CORSRule>
</CORSConfiguration>

when I try to fetch a file (using jQuery with option CrossDomain = true)

from A.example.com -> B.example.com/file.js (works with correct Headers) When I try the same request from another domain : C.dev.example.com -> B.example.com/file.js // (it fails)

However for the second example when I look at the network logs in chrome my first request OPTIONS:

it has the correct CORS response headers :

access-control-allow-headers: access-control-allow-headers
access-control-allow-methods: GET
access-control-allow-origin: *
access-control-max-age: 3000
content-length: 0
date: Mon, 26 Mar 2018 14:38:36 GMT
server: AmazonS3
status: 200
vary: Origin, Access-Control-Request-Headers, Access-Control-Request-Method
via: 1.1 f19281f08e79aa6c6634266c50732dd5.cloudfront.net (CloudFront)
x-amz-cf-id: S2aMKSsJspB9p2RVxLMNh49iQ3Rc0Uims-EEIcjbxC42_OpqJpoUXQ==
x-cache: Miss from cloudfront

However the GET Request (right after the OPTIONS) :

accept-ranges: bytes
content-length: 817
content-type: application/javascript
date: Mon, 26 Mar 2018 14:19:46 GMT
etag: "5b85d498318db8095a776fdcae57c624"
last-modified: Mon, 26 Mar 2018 14:19:20 GMT
server: AmazonS3
status: 200
via: 1.1 f19281f08e79aa6c6634266c50732dd5.cloudfront.net (CloudFront)
x-amz-cf-id: C0xswS08mXDHkagm3phQT59wjclwEX9ZZHXr57OpZVMHzkf432H7dg==
x-cache: RefreshHit from cloudfront

My TTL on the Cloudfront is 5 seconds (It has to be aggressive for my use case) I'm using the h2 protocol instead of the http/1.1

M. Gara
  • 153
  • 2
  • 10