我有一张通过 Rackspace Cloud Files 托管在 CDN 上的图像。我将“Access-Control-Allow-Origin”标头设置为“*”:
curl -I http://ddfe38685b82abf2025a-3d3d68979b9884dbb99ee38fe4e87955.r49.cf1.rackcdn.com/images/ads/6/a6c3d7ec7ca8d8a41a4a065e27e317e2.jpg
HTTP/1.1 200 OK
Content-Length: 1304399
Accept-Ranges: bytes
Last-Modified: Tue, 03 Mar 2015 02:10:06 GMT
ETag: c8767efedb8057eaa637a2caeabed834
X-Timestamp: 1425348605.85405
Access-Control-Allow-Origin: *
Content-Type: image/jpeg
X-Trans-Id: tx5115bede82244690acd6a-0054f51e84dfw1
Cache-Control: public, max-age=259200
Expires: Fri, 06 Mar 2015 02:37:57 GMT
Date: Tue, 03 Mar 2015 02:37:57 GMT
Connection: keep-alive
但是,当我尝试通过 AJAX 下载此文件时,我得到No 'Access-Control-Allow-Origin' header is present on the requested resource
:
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://ddfe38685b82abf2025a-3d3d68979b9884dbb99ee38fe4e87955.r49.cf1.rackcdn.com/images/ads/6/a6c3d7ec7ca8d8a41a4a065e27e317e2.jpg', true);
xhr.send();
当明确设置“访问控制允许来源”时,为什么我会收到此错误的任何想法?