CORS issue while redirecting to Keycloak Login Page #15962
Replies: 12 comments 4 replies
-
|
i have literally the same problem. Yet no solution found |
Beta Was this translation helpful? Give feedback.
-
|
Afaic I implemented this by having the Angular frontend triggers the authentication by itself through a public clientId. The backend uses a bearer-only clientId. Actually I set "*" for Web Origins and Valid Redirect URIs of my public clientId but I guess I could have been more restrictive. |
Beta Was this translation helpful? Give feedback.
-
|
Admittedly, I am not familiar with Angular, but as far as I understand, CORS errors occur when the frontend Javascript engine attempts to fetch the response itself from Keycloak using an XMLHttpRequest (which is transparent for the user). However, the SSO needs to validate the request entirely, in a client-agnostic way, and the request cannot be transparent from the user (especially if user consent is required). Because of this, the browser must create an entirely new request to the SSO, and the request should be visible to the user. From what I can see, a functional approach is creating a |
Beta Was this translation helpful? Give feedback.
-
Hi, I am also facing this problem. Did you get a solution for this? |
Beta Was this translation helpful? Give feedback.
-
|
I have the same problem Access to XMLHttpRequest at 'http://localhost:8080/auth/realms/arqgrifo/.well-known/openid-configuration' from origin 'https://localhost:44337' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. and in my client app Someone can help me? |
Beta Was this translation helpful? Give feedback.
-
|
any news?, I have same problem |
Beta Was this translation helpful? Give feedback.
-
|
Hello, I have the same issue. Im using react and spring cloud gateway for redirect all request to my microservices. |
Beta Was this translation helpful? Give feedback.
-
|
I have the same issue. I'm using Flutter Web. |
Beta Was this translation helpful? Give feedback.
-
|
same issue right, configs in keykloak re similar, not sure how to solve this |
Beta Was this translation helpful? Give feedback.
-
|
Same issue on React JS right now, |
Beta Was this translation helpful? Give feedback.
-
|
Dear everyone, i just found solution. (No CORS problem) The solution i found from this stackoverflow. For me, i integrate Keyclock with NextJS and i found some useful article about 2 stacks technologies with Next-auth: : medium article. package local-cors-proxy worked like a charm for me. |
Beta Was this translation helpful? Give feedback.
-
|
I hit this problem while hosting Keycloak on Kubernetes behind an ingress-nginx proxy. I needed to add this annotation to the ingress:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a simple Rest API written in Spring Boot. I have implemented OAuth2 with Keycloak. I have a UI written in Angular.
My expectation is, when I hit the API url from the Angular Page (say a Button click), I should be redirected to Keycloak Login Page. But when I try to access the API from Angular Application, I am getting the below error.
Access to XMLHttpRequest at 'http://localhost:8080/realms/CloudBrokerRealm/protocol/openid-connect/auth?response_type=code&client_id=cloud-broker-client2&scope=openid&state=pgUtz5IX5ONC3NQ6o9v3IbPnB2DB9rUr3O40tuRxGHY%3D&redirect_uri=http://localhost:8085/login/oauth2/code/keycloak&nonce=CjpTbFvhBqxD0Rz4SQk49rT-wsB3C279NlGHDExlh6M' (redirected from 'http://localhost:8085/scheduler/read') from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
When I hit the API http://localhost:8085/scheduler/read by clicking a Button from Angular, It is trying to redirect to Keycloak Login page but due to CORS error, Login page of Keycloak is not coming.
For accessing the backend API http://localhost:8085/scheduler/read , I have done the CORS configuration in Spring Boot and no CORS issues with this API when I directly accessing this API url from browser and Keycloak Login Page is coming. But the issue is occurring when from Angular Application running in http://localhost:4200 , we are trying to hit the API and it is trying to redirect to Keycloak Login Page http://localhost:8080/realms/CloudBrokerRealm/protoco.......
I have added Web Origins in Keycloak under the client but still CORS issue persists. Is there any way to bypass the CORS issue or can we disable the CORS in Keycloak. I am running Keycloak as a docker container image
quay.io/keycloak/keycloak:18.0.2.Beta Was this translation helpful? Give feedback.
All reactions