Problem with CORS loading images from CDN

CORS doesn’t apply to image tags in html documents, which is why the image would work via an <img /> tag.

If you are requesting the same resource, but via JavaScript, then you may run into CORS problems. In order for your code to be allowed to request that image, the server you are requesting it from needs to say it is okay. It says it’s okay by sending some headers back in the response to your request. Look at the network tab in the dev tools and see if there are any “Access-Control-“ headers in that response. If there are not, then the server is telling you that you aren’t allowed to load the resource and you’ll see a CORS error