10
다음 CORS 구성의 S3 버킷이 있습니다.Amazon S3 CORS 헤더는 GET 요청이 아닌 OPTIONS (프리 플라이트)에만 표시됩니다.
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>
프리 플라이트 검사가 예상대로 작동합니다.
★ ~$ curl -i -X OPTIONS -H "Origin: http://stackoverflow.com" -H "Access-Control-Request-Method: GET" https://s3.amazonaws.com/random-stuff-ohyea/coderot.gif
HTTP/1.1 200 OK
x-amz-id-2: H6tzMUCJtYgiCRrhj5DucMhjjYtj1kKWqL7u2yaRGEorOeKhu/sTKlgGqY7uHxQC
x-amz-request-id: E784C4373565CBE6
Date: Mon, 21 Oct 2013 22:14:18 GMT
Access-Control-Allow-Origin: http://stackoverflow.com
Access-Control-Allow-Methods: GET
Access-Control-Max-Age: 3000
Access-Control-Allow-Credentials: true
Vary: Origin, Access-Control-Request-Headers, Access-Control-Request-Method
Content-Length: 0
Server: AmazonS3
그러나 GET 요청의 원본 헤더는 그렇지 않습니다.
★ ~$ curl -iI -H "Origin: http://stackoverflow.com" https://s3.amazonaws.com/random-stuff-ohyea/coderot.gif
HTTP/1.1 200 OK
x-amz-id-2: KlrSviRSwq/40zPwOGp2/lJZk0J2Fyu7kOg966osOvQ2mpbpiv5BLkihGSOfoLd8
x-amz-request-id: 9D051B0001F48AB7
Date: Mon, 21 Oct 2013 22:11:57 GMT
Last-Modified: Mon, 21 Oct 2013 22:10:53 GMT
ETag: "4fa16333380378e116479646b40dd1ee"
Accept-Ranges: bytes
Content-Type: image/gif
Content-Length: 1774246
Server: AmazonS3
내 s3 버켓에있는 원격 글꼴을로드 할 때 firefox가 프리 플라이트 확인을하지 않는 것 같아서이 점은 중요합니다. 원본 헤더 만 보내는 것 같습니다.
추가 디버깅은 "액세스 제어 요청 방법 : GET"헤더를 내 요청에 포함 시키면 올바른 CORS 헤더를 다시 얻음을 보여 주지만 파이어 폭스는이를 수행하지 않습니다. – reconbot
기본적으로 공상적인 GET 요청은 프리 플라이트 확인을 수행하지 않습니다. [W3 Spec] (http://www.w3.org/TR/cors/#cross-origin-request-with-preflight-0), [MDN] (https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS # Preflighted_requests) –