# CORS Error when trying to fetch image from GhostAPI

**URL:** <https://forum.ghost.org/t/cors-error-when-trying-to-fetch-image-from-ghostapi/39912>\
**Category:** Developer help\
**Created:** [July 18, 2023, 7:28am UTC](https://forum.ghost.org/t/cors-error-when-trying-to-fetch-image-from-ghostapi/39912 "2023-07-18T07:28:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abdul\_codeller](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/abdul_codeller/32/25457_2.png) [@abdul\_codeller](https://forum.ghost.org/u/abdul_codeller)\
**Post date:** [July 18, 2023, 7:28am UTC](https://forum.ghost.org/t/cors-error-when-trying-to-fetch-image-from-ghostapi/39912/1 "2023-07-18T07:28:04Z")

</div>

Hi ,  
I’m using ghost API in my website where I display blogs from ghost Platform.  
I’m trying to fetch the Image of my blog for SEO purpose but I’m Facing **CORS** error while doing so.  
Here is my fetch code and a example image I’m trying to fetch.

**Code** :

```auto
 const response = await fetch("https://dangdi.ghost.io/content/images/size/w1600/format/avif/2023/05/Screenshot-2023-05-31-083805.png"), {
  headers: {
      Origin: window.location.origin,
      "Access-Control-Request-Method": "GET",
      "Access-Control-Request-Headers": "Content-Type",
      "sec-fetch-dest": "image",
    },
});

```

**Error** :  
 ![Screenshot from 2023-07-18 12-19-41](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/3X/1/5/15e57f1ac03c80571f6d69e9c88d702025a7642b.png)

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [July 18, 2023, 10:41am UTC](https://forum.ghost.org/t/cors-error-when-trying-to-fetch-image-from-ghostapi/39912/2 "2023-07-18T10:41:24Z")

</div>

Try adding `mode: "cors"` to your fetch request.

```auto
 const response = await fetch("https://dangdi.ghost.io/content/images/size/w1600/format/avif/2023/05/Screenshot-2023-05-31-083805.png"), {
   mode: "cors",
   headers: {
      Origin: window.location.origin,
      "Access-Control-Request-Method": "GET",
      "Access-Control-Request-Headers": "Content-Type",
      "sec-fetch-dest": "image",
    },
});

```

If it’s still not working, check that you don’t have a reverse proxy set up to protect images from hot-linking, and temporarily turn off any and all proxying setting you might have on. (I think Cloudflare offers hotlink protection this as a configurable option on their domains.) If that fixes it, then you’ll know that the problem is there and you can try to fix the configuraiton.
