Do you know that Chromium browser (Chrome, Edge, Brave) will use cached image even though the CORS constraint is different? if you’re about to do image processing / image manipulation in the browser / canvas, it will be helpful to know this quirk
If Chrome has fetched an image without crossorigin attribute, when the cache time is still active and there is another request to the same image with crossorigin attribute, Chrome will serve the 2nd request from cache instead of fetching it over the network again
<!-- 1st request -->
<img src="abc.png" />
<!-- 2nd request -->
<img src="abc.png" crossorigin="anonymous" />Why is that a problem? because the CORS constraint between 1st and 2nd request is different, thus the 2nd request will return CORS error, which is unexpected by the dev
This is a known issue for a long time and Chromium developer already marked it as a Wont-Fix (issue #40381978). Firefox and Safari doesn’t have this issue though, so you have to workaround it, you got 2 option:
1st solution
If you know the image will always be processed / manipulated in the canvas, it’s better to consistently use the same CORS attribute in the DOM element throughout your app
<img src="abc.png" crossorigin="anonymous" />
<img src="abc.png" crossorigin="anonymous" />2nd solution
If the 1st option is not in your control or quite a hassle, you can easily add an additional query string into the 2nd request, so it will skip the cache
<img src="abc.png" />
<img src="abc.png?canvas=1" crossorigin="anonymous" />I hope this is useful, have a nice day!