import '@angular/compiler'; import { bootstrapApplication } from '@angular/platform-browser'; import { provideZonelessChangeDetection } from '@angular/core'; import { provideHttpClient, withFetch, withInterceptors } from '@angular/common/http'; import Keycloak from 'keycloak-js'; import { AppComponent } from './src/app.component'; import { KEYCLOAK_INSTANCE } from './src/core/tokens/keycloak.token'; import { authInterceptor } from './src/core/interceptors/auth.interceptor'; const keycloak = new Keycloak({ url: 'http://localhost:8080', realm: 'scommettiapp', clientId: 'scommetti-frontend', }); keycloak.init({ onLoad: 'login-required', checkLoginIframe: false, pkceMethod: 'S256', }).then(authenticated => { if (!authenticated) { keycloak.login(); return; } bootstrapApplication(AppComponent, { providers: [ provideZonelessChangeDetection(), provideHttpClient(withFetch(), withInterceptors([authInterceptor])), { provide: KEYCLOAK_INSTANCE, useValue: keycloak }, ], }).catch(err => console.error(err)); }).catch(err => { console.error('Keycloak initialization failed:', err); });