That's a caching issue, and a chrome bug*:
*Closed as WONT-FIX, chrome devs said it isn't a bug per se, it's a misconfiguration of the server which should send the allow origin headers to any requests... A related bug report, also closed as WONT-FIX.
You probably already had made a request to this image without requesting for the CORS headers.
When you perform the second request, the browser will wrongly reuse the cached response.
var rand = '?'+Math.random();
var no_cors = new Image();
no_cors.onload = loadCORS;
no_cors.src = 'https://s3.amazonaws.com/ch-static-beta/avatar/user/1a8fdd22d5ec11e784da0e28350150f71512059569.png' + rand;
function loadCORS(){
var with_cors = new Image();
with_cors.crossOrigin = 'anonymous';
with_cors.src = no_cors.src;
with_cors.onload = function(){console.log('loaded');};
with_cors.onerror = function(){console.error('failed');};
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…