title: KeyCloak Login leads to infinite loop
body: <p>I have recently started using KeyCloak with Angular. My KeyCloak Docker is running on Port 8080, and my Angular-Application is running on 4200. Now when I access my app through the browser I get redirected to <code>auth/realms/...</code> with the appropriate redirect-url. Thats the expected behaviour so far. However, before the KeyCloak login page even loads I get redirected back to <code>auth/realms/...</code>, but this time my redirect-url is the old <code>auth/realms/...</code> I had just before.</p>
  
  <p>The problem seems to be not KeyCloak itself, but my Angular implementation, since even if I disable my KeyCloak client or access the wrong client I get the same behaviour.</p>
  
  <p>Now for some code. I have set up my KeyCloakOptions like this:</p>
  
  <pre><code>export const keycloakOptions: KeycloakOptions = {
    config: {
      url: '/auth',
      realm: 'bookstore',
      clientId: 'bookstore-front-end'
    },
    initOptions: {
      onLoad: 'login-required',
      checkLoginIframe: false
    },
    enableBearerInterceptor: true,
    bearerExcludedUrls: ['/assets']
  };
  </code></pre>
  
  <p>And the Service is initialized like this:</p>
  
  <pre><code>export class AppModule implements DoBootstrap {
  
    public ngDoBootstrap(appRef: ApplicationRef): void {
      keycloakService
        .init(keycloakOptions)
        .then(() =&gt; {
          console.log('[ngDoBootstrap] bootstrap app');
          appRef.bootstrap(AppComponent);
        })
        .catch(error =&gt; console.error('[ngDoBootstrap] init Keycloak failed', error));
    }
  }
  </code></pre>
  
  <p>I have the suspicion that my app routing has something to do with the problem. It looks like this:</p>
  
  <pre><code>const routes: Routes = [
    // home route protected by auth guard
    {path: 'books', component: BooksComponent, canActivate: [AuthGuard]},
  
    // otherwise redirect to home
    {path: '', redirectTo: 'books', pathMatch: 'full'}
  ];
  </code></pre>
  
  <p>If you need any further code please let me know, any help is apprechiated.</p>
  
  <p>EDIT:</p>
  
  <p>My first request looks like this:</p>
  
  <pre><code>http://localhost:4200/auth/realms/bookstore/protocol/openid-connect/auth?client_id=bookstore-front-end&amp;redirect_uri=http%3A%2F%2Flocalhost%3A4200%2F&amp;state=c530f55a-b21e-43c3-8e1c-a3beb134c9ee&amp;response_mode=fragment&amp;response_type=code&amp;scope=openid&amp;nonce=0c359787-92e7-4d6d-9578-a65da686b046
  </code></pre>
  
  <p>However I just realized that in the body of my response I am getting the <code>index.html</code> file of my Application, which is strange.</p>