'angular13 - keycloak cors config is invalid

I am using keycloak authentication app. I am using angular13 in UI. I am sending the post request for login as follows.

But the cors settings problem returns. On the keycloak side, I configured the cors settings as follows. But I keep getting errors.

private apiUrl:string = `${environment.baseUrl}`;

constructor(private httpClient:HttpClient) { }

IsAuthentication(username:string, password:string){
  let body = new URLSearchParams();
  body.set("client_id", environment.client_id);
  body.set("grant_type", environment.grant_type);
  body.set("username", username);
  body.set("password", password);

  console.log(body);

  return this.httpClient.post<any>(`${this.apiUrl}/services/auth/openid-connect/token`, body);
}

enter image description here

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source