Files
ROLAC/APP/src/app/app.config.ts
T
Chris Chen 3558c67fd7 WIP
2026-06-20 17:51:33 -07:00

26 lines
1.0 KiB
TypeScript

import { ApplicationConfig, APP_INITIALIZER } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideHttpClient, withInterceptors } from '@angular/common/http';
import { routes } from './app.routes';
import { authInterceptor } from './core/interceptors/auth.interceptor';
import { httpErrorInterceptor } from './core/interceptors/http-error.interceptor';
import { AuthService } from './shared/services/auth.service';
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideAnimations(),
// httpErrorInterceptor is listed first so its catchError runs LAST (outermost),
// i.e. after authInterceptor has handled/retried 401s.
provideHttpClient(withInterceptors([httpErrorInterceptor, authInterceptor])),
{
provide: APP_INITIALIZER,
useFactory: (authService: AuthService) => () => authService.initializeFromRefreshToken(),
deps: [AuthService],
multi: true,
},
]
};