# Access-Control-Allow-Origin

**URL:** <https://forum.keycloak.org/t/access-control-allow-origin/10585>\
**Category:** Getting advice\
**Created:** [August 18, 2021, 9:13am UTC](https://forum.keycloak.org/t/access-control-allow-origin/10585 "2021-08-18T09:13:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![aggoun](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@aggoun](https://forum.keycloak.org/u/aggoun)\
**Post date:** [August 18, 2021, 9:13am UTC](https://forum.keycloak.org/t/access-control-allow-origin/10585/1 "2021-08-18T09:13:46Z")

</div>

Hello to all,  
I’m using `angular 11` with `Keycloak 12.0.4`,I have a problem with the CORS policy for my public URLs, I’m stuck on it since two days, despite the fact that I found topics talking about the same problem and tried what was suggested on the answers, I could not solve the problem.

i tried this  
[https://stackoverflow.com/questions/45051923/keycloak-angular-no-access-control-allow-origin-header-is-present](https://stackoverflow.com/questions/45051923/keycloak-angular-no-access-control-allow-origin-header-is-present)  
and it didn’t work for me

here is the error message and the configuration of the client keycloak:

> ‘[http://localhost:4200](http://localhost:4200/)’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/d/d46ce67e5dfa86ee504af9bc60531bfb0d13f75f.png)

Someone has an idea of what I should do ?

THANK YOU IN ADVENCED

---

<div class="post-metadata">

**Author:** ![aggoun](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@aggoun](https://forum.keycloak.org/u/aggoun)\
**Post date:** [August 18, 2021, 9:54am UTC](https://forum.keycloak.org/t/access-control-allow-origin/10585/2 "2021-08-18T09:54:42Z")

</div>

@jominga , @jangaraj , @elenajp, @kerstel @daryaorel @Najm_R @ibrabool @spagop @nejcn001 @Vrokn

i will be grateful if you can help me 🙏

---

<div class="post-metadata">

**Author:** ![aggoun](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@aggoun](https://forum.keycloak.org/u/aggoun)\
**Post date:** [August 18, 2021, 9:55am UTC](https://forum.keycloak.org/t/access-control-allow-origin/10585/3 "2021-08-18T09:55:06Z")

</div>

@kevinarthur @Johannes @uugan , @opsnull , @littleboss @karolalexander@khteh@reinhapa@ola.sheryf@apellizzn

i will be grateful if you can help me 🙏

---

<div class="post-metadata">

**Author:** ![aggoun](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@aggoun](https://forum.keycloak.org/u/aggoun)\
**Post date:** [August 18, 2021, 9:55am UTC](https://forum.keycloak.org/t/access-control-allow-origin/10585/4 "2021-08-18T09:55:33Z")

</div>

@mlleal @crozarakamilla @aludwig @R4nmaru @Ziefin @roastedcpu @AAverin @zonaut @chefban @kevcal69

i will be grateful if you can help me 🙏

---

<div class="post-metadata">

**Author:** ![aggoun](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@aggoun](https://forum.keycloak.org/u/aggoun)\
**Post date:** [August 18, 2021, 9:55am UTC](https://forum.keycloak.org/t/access-control-allow-origin/10585/5 "2021-08-18T09:55:45Z")

</div>

@afvg @igorroman777 @blanchjj @Robinyo @cinhil @VincentSch4rf @abstractj

i will be grateful if you can help me 🙏

---

<div class="post-metadata">

**Author:** ![jominga](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@jominga](https://forum.keycloak.org/u/jominga)\
**Post date:** [August 18, 2021, 10:16am UTC](https://forum.keycloak.org/t/access-control-allow-origin/10585/6 "2021-08-18T10:16:48Z")

</div>

Funny, I faced this exact problem yesterday.

My solution was:

1. Go to your realm
2. Go to “Roles” and select “Default Roles”
3. Go to “Client Roles” and select “account”
4. Add “view-profile” to Client Default Roles

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![R4nmaru](https://avatars.discourse-cdn.com/v4/letter/r/a4c791/32.png) [@R4nmaru](https://forum.keycloak.org/u/R4nmaru)\
**Post date:** [August 18, 2021, 12:02pm UTC](https://forum.keycloak.org/t/access-control-allow-origin/10585/7 "2021-08-18T12:02:51Z")

</div>

Check under Client scopes if you added “web-origins” to the Assigned Default Client Scopes

---

<div class="post-metadata">

**Author:** ![aggoun](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@aggoun](https://forum.keycloak.org/u/aggoun)\
**Post date:** [August 18, 2021, 1:02pm UTC](https://forum.keycloak.org/t/access-control-allow-origin/10585/8 "2021-08-18T13:02:56Z")

</div>

@jominga thank you for answering me,  
it is already selected,  
I always have the error.

 ![3](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/a/af69227c98ce302fa2751cabe3fbcd3913c5f8f5.png)

---

<div class="post-metadata">

**Author:** ![aggoun](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@aggoun](https://forum.keycloak.org/u/aggoun)\
**Post date:** [August 18, 2021, 1:03pm UTC](https://forum.keycloak.org/t/access-control-allow-origin/10585/9 "2021-08-18T13:03:50Z")

</div>

@R4nmaru thank you for answering me,  
it is already selected,  
I always have the error.

 ![2](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/e/e5bd3db949aa8f3034e74bd2241f7d51d18b3d2e.png)

---

<div class="post-metadata">

**Author:** ![R4nmaru](https://avatars.discourse-cdn.com/v4/letter/r/a4c791/32.png) [@R4nmaru](https://forum.keycloak.org/u/R4nmaru)\
**Post date:** [August 18, 2021, 1:58pm UTC](https://forum.keycloak.org/t/access-control-allow-origin/10585/10 "2021-08-18T13:58:03Z")

</div>

you can try changing the Fine Grain OpenID Connect Configuration for Access and Id token to RS256 or try to toggle on full Scope allowed under “Scope”

---

<div class="post-metadata">

**Author:** ![aggoun](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@aggoun](https://forum.keycloak.org/u/aggoun)\
**Post date:** [August 20, 2021, 8:17am UTC](https://forum.keycloak.org/t/access-control-allow-origin/10585/11 "2021-08-20T08:17:04Z")

</div>

At the beginning i tested my public ROOT with Postman and it’s OK, so i thaught that the problem is on the frontend part or Keycloak,  
i tried lot of proposed solutions and nothing worked,

Finally the problem was on the backand,  
as I’m using spring boot I added this header to my method response

```auto
        HttpHeaders headers = new HttpHeaders();
        headers.set("Access-Control-Allow-Origin", "*");

       return ResponseEntity.ok().headers(headers).body(Data);

```
