From 9b1b2c468254ebcc5dd815708a78abb7ff981d53 Mon Sep 17 00:00:00 2001 From: Nino Date: Fri, 20 Dec 2024 16:28:35 +0100 Subject: [PATCH] Angular Service Worker insert Bypass in Req Header for Network Req --- apps/isa-app/src/app/app-swagger.module.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/isa-app/src/app/app-swagger.module.ts b/apps/isa-app/src/app/app-swagger.module.ts index d37d0f26a..653583138 100644 --- a/apps/isa-app/src/app/app-swagger.module.ts +++ b/apps/isa-app/src/app/app-swagger.module.ts @@ -1,3 +1,4 @@ +import { HttpInterceptorFn, provideHttpClient, withInterceptors } from '@angular/common/http'; import { NgModule } from '@angular/core'; import { Config } from '@core/config'; import { AvConfiguration } from '@swagger/availability'; @@ -17,8 +18,13 @@ export function createConfigurationFactory(name: string) { }; } +const serviceWorkerInterceptor: HttpInterceptorFn = (req, next) => { + return next(req.clone({ setHeaders: { 'ngsw-bypass': 'true' } })); +}; + @NgModule({ providers: [ + provideHttpClient(withInterceptors([serviceWorkerInterceptor])), { provide: AvConfiguration, useFactory: createConfigurationFactory('av'), deps: [Config] }, { provide: CatConfiguration, useFactory: createConfigurationFactory('cat'), deps: [Config] }, { provide: CheckoutConfiguration, useFactory: createConfigurationFactory('checkout'), deps: [Config] },