Angular Keycloak : Window undefined

Discussão em 'Angular' iniciado por yosr sellami, Janeiro 25, 2025.

  1. yosr sellami

    yosr sellami Guest

    Hello I have some problems with Angular and Keycloak because of window.location.origin in this function but in the tutorial that I follow he did like that and it works, plz could you help me to solve it !! The error is window undefined



    function initializeKeycloak(keycloak: KeycloakService) {
    return () =>
    keycloak.init({
    config: {
    url: 'http://localhost:8080',
    realm: 'zetta',
    clientId: 'zetta-client'
    },
    initOptions: {
    onLoad: 'check-sso',
    silentCheckSsoRedirectUri:
    //the problem is here
    window.location.origin + '/assets/silent-check-sso.html'
    }
    });
    }

    @NgModule({
    declarations: [
    AppComponent,
    SidebarComponent,
    FormationsComponent,




    ],
    imports: [
    BrowserModule,
    BrowserAnimationsModule,
    AppRoutingModule,
    HttpClientModule,
    ReactiveFormsModule,
    FormsModule,
    RouterModule,
    KeycloakAngularModule


    ],
    providers: [
    provideClientHydration(),
    {
    provide: APP_INITIALIZER,
    useFactory: initializeKeycloak,
    multi: true,
    deps: [KeycloakService]
    }
    ],
    bootstrap: [AppComponent]
    })
    export class AppModule { }


    This is the app.module.ts

    Continue reading...

Compartilhe esta Página