RED-3800 added x-tenant-id header for backend compatiblity on multi-tenancy

This commit is contained in:
Timo Bejan 2022-07-20 15:40:47 +03:00
parent 67b2297374
commit b69c4de4bb
2 changed files with 19 additions and 0 deletions

View File

@ -55,6 +55,7 @@ import { ILoggerConfig } from '@red/domain';
import { SystemPreferencesService } from '@services/system-preferences.service';
import { PdfViewerModule } from './modules/pdf-viewer/pdf-viewer.module';
import { LicenseService } from '@services/license.service';
import { TenantIdInterceptor } from '@utils/tenant-id-interceptor';
export function httpLoaderFactory(httpClient: HttpClient, configService: ConfigService): PruningTranslationLoader {
return new PruningTranslationLoader(httpClient, '/assets/i18n/', `.json?version=${configService.values.FRONTEND_APP_VERSION}`);
@ -168,6 +169,11 @@ const components = [AppComponent, AuthErrorComponent, NotificationsComponent, Sp
multi: true,
useClass: ApiPathInterceptor,
},
{
provide: HTTP_INTERCEPTORS,
multi: true,
useClass: TenantIdInterceptor,
},
{
provide: HTTP_INTERCEPTORS,
multi: true,

View File

@ -0,0 +1,13 @@
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
@Injectable()
export class TenantIdInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
const updatedRequest = req.clone({
setHeaders: { 'X-TENANT-ID': 'redaction' },
});
return next.handle(updatedRequest);
}
}