Ich habe einen S3-Bucket mit der folgenden CORS-Konfiguration.Amazon S3 CORS-Header werden nur während OPTIONEN (Preflight) und nicht während der GET-Anforderung angezeigt
<?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>
Der Preflight-Check funktioniert wie erwartet.
★ ~$ 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
Die Herkunft Kopfzeile auf einer GET-Anfrage nicht jedoch.
★ ~$ 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
Dies ist wichtig, weil Firefox scheint nicht Preflight zu tun, wenn Remote-Schriftarten laden, die ich in meinem s3 Eimer haben. Es scheint nur den Ursprungsheader zu senden.
Weitere Debugging zeigt, dass wenn ich eine "Access-Control-Request-Methode: GET" -Header in meine Get-Anfrage, bekomme ich die richtigen CORS-Header zurück, Firefox tut dies jedoch nicht. – reconbot
Eine nicht-ausgefallene GET-Anfrage führt standardmäßig keine Preflight-Prüfung durch. [W3 Spec] (http://www.w3.org/TR/cors/#cross-origin-request-with-preflight-0), [MDN] (https://developer.mozilla.org/en-US/docs/HTTP/Zugriffssteuerung_CORS # Preflighted_requests) –