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.
here is the error message and the configuration of the client keycloak:
‘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
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
HttpHeaders headers = new HttpHeaders();
headers.set("Access-Control-Allow-Origin", "*");
return ResponseEntity.ok().headers(headers).body(Data);