I cannot navigate to the dashboard page after logging in keycloak in angular

546 Views Asked by At

I get the following error

enter image description here

I added the codes as follows. Keycloak login screen appears. Cannot be redirect after login.

const keycloak_config = config.keycloak;
  this.keycloakAuth = Keycloak(keycloak_config);
  this.keycloakAuth.redirectUri = environment.baseUrl + '/dashboard' ;
  this.keycloakAuth.init({onLoad: 'login-required',
    checkLoginIframe: false})
    .success(() => {
      resolve();
   })
    .error(() => {
      reject();
    });

One of the information in the environment file;

baseUrl: 'http://localhost:4200'

code block in app-routing.module.ts. I done useHash : false. Because if useHash : true, page is not open. I get error so;

Error: Cannot match any routes. URL Segment: 'state' Error: Cannot match any routes. URL Segment: 'state' at Anonymous function (http://localhost:4200/vendor.js:82718:17) at CatchSubscriber.prototype.error

const routes: Routes = [
  {
    path: '',
    component: ContentLayoutComponent,
    children: CONTENT_ROUTES,
    canActivate: [AuthGuard]
  },
  {
    path: 'login',
    component: AuthLayoutComponent
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes, {useHash: false, scrollPositionRestoration: 'enabled'})],
  exports: [RouterModule]
})
export class AppRoutingModule { }
0

There are 0 best solutions below