# CORS issue with Ghost Content API

**URL:** <https://forum.ghost.org/t/cors-issue-with-ghost-content-api/38955>\
**Category:** Developer help\
**Created:** [June 5, 2023, 9:54am UTC](https://forum.ghost.org/t/cors-issue-with-ghost-content-api/38955 "2023-06-05T09:54:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Muazzam\_Ali](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/muazzam_ali/32/24763_2.png) [@Muazzam\_Ali](https://forum.ghost.org/u/Muazzam_Ali)\
**Post date:** [June 5, 2023, 9:54am UTC](https://forum.ghost.org/t/cors-issue-with-ghost-content-api/38955/1 "2023-06-05T09:54:08Z")

</div>

Hi I am using Angular Universal and my angular version is 15. I just setup a Ghost Pro (v5.0) account with the sole purpose of using the content API for my blog (not launched in production yet). The goal is to make http request from angular universal to ghost api to get the content and show them on my website.

My goal is to optimize my website for SEO by writing blogs using ghost pro CMS.

The problem is with CORS i.e whenever I make a request to the api

`https://grocera.ghost.io/ghost/api/v3/content/posts/?key=[MY_KEY]&fields=slug,title,feature_image,excerpt&include=authors`

I get a CORS issue because the domain I’m making request from (in this case [http://localhost:4200](http://localhost:4200)) is not whitelisted on ghost server. SO the question is how can I whitelist domains to make an http request to ghost server ?

Is there some kind of admin dashboard ? Or code examples ?

To Recreate the problem:

You can simply setup a ghost account locally (with no changes). Setup an angular application and make and http request to the ghost server to load content.

---

<div class="post-metadata">

**Author:** ![RyanF](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ryanf/32/17448_2.png) [@RyanF](https://forum.ghost.org/u/RyanF)\
**Post date:** [June 5, 2023, 1:54pm UTC](https://forum.ghost.org/t/cors-issue-with-ghost-content-api/38955/2 "2023-06-05T13:54:55Z")

</div>

You shouldn’t receive a CORS error when calling the Content API.

Are you able to share the code for how you’re calling the API? Or try calling the API from a simple JS file to help troubleshoot the error?

---

<div class="post-metadata">

**Author:** ![markstos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/markstos/32/18182_2.png) [@markstos](https://forum.ghost.org/u/markstos)\
**Post date:** [June 5, 2023, 3:39pm UTC](https://forum.ghost.org/t/cors-issue-with-ghost-content-api/38955/3 "2023-06-05T15:39:20Z")

</div>

Sharing the exact CORS error message you are seeing and where you are seeing it could be helpful to.

When I make a request to my own Ghost Content API it includes this header in the reply:

```auto
Access-Control-Allow-Origin: *
Vary: Accept-Version, Accept-Encoding

```

From reading here: [Access-Control-Allow-Origin - HTTP | MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin)

This does indicate that requests from any origin should be allowed.

---

<div class="post-metadata">

**Author:** ![Muazzam\_Ali](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/muazzam_ali/32/24763_2.png) [@Muazzam\_Ali](https://forum.ghost.org/u/Muazzam_Ali)\
**Post date:** [June 8, 2023, 8:50am UTC](https://forum.ghost.org/t/cors-issue-with-ghost-content-api/38955/4 "2023-06-08T08:50:59Z")

</div>

Found the solution.

After digging into the error I got in the chrome browser console. I found the following part of the message to be the key to understanding the problem.

_The value of the ‘Access-Control-Allow-Origin’ header in the response must not be the wildcard '_’ when the request’s credentials mode is ‘include’.\*

The request credentials mode was ‘include’ because I’ve set the “withCredentials” to true in my header parameters as shown [here](https://angular.io/guide/http#requesting-data-from-a-server).

Setting it to false did the trick.
