AltitudeWeb/frontend/src/app/app.config.ts

27 lines
887 B
TypeScript
Raw Normal View History

import {ApplicationConfig, provideZoneChangeDetection} from '@angular/core';
import {provideRouter} from '@angular/router';
import {JwtHelperService, JwtModule} from '@auth0/angular-jwt';
import {CookieService} from 'ngx-cookie-service';
2025-04-02 17:18:39 +00:00
import {routes} from './app.routes';
2025-04-02 17:18:39 +00:00
// Function to get the JWT token from cookies
export function jwtTokenGetter() {
const cookieService = new CookieService(document, null);
return cookieService.check('jwt') ? cookieService.get('jwt') : null;
}
2025-04-02 17:18:39 +00:00
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({eventCoalescing: true}),
provideRouter(routes),
{ provide: CookieService, useClass: CookieService },
{ provide: JwtHelperService, useClass: JwtHelperService },
{ provide: JwtModule, useValue: JwtModule.forRoot({
config: {
tokenGetter: jwtTokenGetter
}
})}
]
2025-04-02 17:18:39 +00:00
};