{"id":864,"date":"2024-05-07T11:44:40","date_gmt":"2024-05-07T11:44:40","guid":{"rendered":"https:\/\/kb.shortpixel.com\/docs\/warning-access-to-image-has-been-blocked-by-cors-policy\/"},"modified":"2025-08-27T08:41:41","modified_gmt":"2025-08-27T08:41:41","password":"","slug":"warning-access-to-image-has-been-blocked-by-cors-policy","status":"publish","type":"docs","link":"https:\/\/kb.shortpixel.com\/knowledge-base\/article\/warning-access-to-image-has-been-blocked-by-cors-policy\/","title":{"rendered":"Warning: Access to ___ has been blocked by CORS policy"},"content":{"rendered":"<p>\n\t When using ShortPixel Adaptive Images, you might end up in certain cases with a CORS warning that looks like this:<\/p>\n<blockquote><p>\n  Warning: access to image<br \/>\n\t<code>and-the-image-url-goes-here<\/code>&nbsp;has been blocked by CORS policy: No &#8216;Access-Control-Allow-Origin&#8217; header is present on the requested resource.\n<\/p><\/blockquote>\n<p>\n\t This can happen when ShortPixel processes resources &#8211; images, CSS, JS or fonts &#8211; for the first time (check<br \/>\n\t<a href=\"https:\/\/help.shortpixel.com\/article\/132-how-shortpixel-adaptive-images-work\" target=\"_blank\" rel=\"noopener\">this article<\/a> to learn more about how ShortPixel AI works). Every time a resource is visited for the first time, we&#8217;ll return a <a href=\"https:\/\/help.shortpixel.com\/article\/148-why-are-my-images-redirected-from-cdn-shortpixel-ai\" target=\"_blank\" rel=\"noopener\">temporary 307 redirect<\/a> for them (until they are processed by our systems) and this can throw a CORS warning like the one described above.&nbsp;<\/p>\n<p>\n\t There are 2 solutions to this, one which is more permissive (and might fix other CORS issues present on your site) and another more restrictive one, which will address this specific issue.&nbsp;<\/p>\n<section class=\"callout-blue\">\nFor both solutions, <strong>please consult with your hosting provider on how to implement them<\/strong>.<br \/>\n<\/section>\n<p>\n\t The more permissive solution is to add an<br \/>\n\t<code>Access-Control-Allow-Origin<\/code> header on your site&nbsp;in the following way.&nbsp;This will basically allow requests made from any origin:<\/p>\n<pre>Access-Control-Allow-Origin: *\n<\/pre>\n<p>\n\t The more restrictive solution is to add the same<br \/>\n\t<code>Access-Control-Allow-Origin<\/code> header, but with your site domain, for example:<\/p>\n<pre>Access-Control-Allow-Origin: https:\/\/yourdomain.com\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When using ShortPixel Adaptive Images, you might end up in certain cases with a CORS warning that looks like this: Warning: access to image and-the-image-url-goes-here&nbsp;has been blocked by CORS policy: No &#8216;Access-Control-Allow-Origin&#8217; header is present on the requested resource. This can happen when ShortPixel processes resources &#8211; images, CSS, JS or fonts &#8211; for the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[35],"glossaries":[],"doc_tag":[],"class_list":["post-864","docs","type-docs","status-publish","hentry","doc_category-shortpixel-adaptive-images"],"blocksy_meta":[],"year_month":"2026-05","word_count":204,"total_views":"1110","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"admin","author_nicename":"admin_mdli53m5","author_url":"https:\/\/kb.shortpixel.com\/author\/admin_mdli53m5\/"},"doc_category_info":[{"term_name":"ShortPixel Adaptive Images","term_url":"https:\/\/kb.shortpixel.com\/knowledge-base\/category\/shortpixel-adaptive-images\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/864","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/comments?post=864"}],"version-history":[{"count":1,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/864\/revisions"}],"predecessor-version":[{"id":2394,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/864\/revisions\/2394"}],"wp:attachment":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/media?parent=864"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_category?post=864"},{"taxonomy":"glossaries","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/glossaries?post=864"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_tag?post=864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}