0

I integrated KeyCloak to my Angular app. Once I run the app, I get redirected to the KeyCloak login. So far so good. If I enter wrong username / password, it will tell me that its wrong. Once I put in the correct credentials, it redirects me to my app but then It just keeps refreshing and refreshing. It seems that it's sending a login request every second.

Here is what log gives me:

enter image description here

I am sure that the problem is not in the logic of the code, but maybe in configuration. I googled the error and saw that things like changing

localhost:8080

to

127.0.0.1:8080

could fix the problem, but it didn't do anything in my case.

Dino
  • 6,207
  • 8
  • 28
  • 62

2 Answers2

0

The problem had nothing to do with KeyCloak setup. It was in

app.module.ts

In one of my services I had HashLocationStrategy instead of PathLocationStrategy.

-    useClass: HashLocationStrategy
+    useClass: PathLocationStrategy

So my providers look something like this now:

providers: [
  KeyCloakService,
  AssetService,
    {
     provide: LocationStrategy,
     useClass: PathLocationStrategy
    }
  ]
Dino
  • 6,207
  • 8
  • 28
  • 62
0

Something was happening to me too. Try disabling cors on the browser (Disable same origin policy in Chrome) or set the Web Origin set in keycloak

Pako
  • 329
  • 2
  • 5
  • 18