From 5267eb6ab1a82ba379935dee512eba1383fc084e Mon Sep 17 00:00:00 2001 From: eneller Date: Tue, 4 Mar 2025 23:07:45 +0100 Subject: [PATCH] fix: serviceworker doesnt intercept other urls since i am using the same subdomain also for '/redirects', they were being intercepted by the service worker chrome now blocks the redirect altogether because of CORS when redirects are not allowed (default on linux chromium) --- ngsw-config.json | 8 ++++++++ src/app/app.config.ts | 8 +++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ngsw-config.json b/ngsw-config.json index 69edd28..070175d 100644 --- a/ngsw-config.json +++ b/ngsw-config.json @@ -25,6 +25,14 @@ "/**/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)" ] } + }, + { + "name": "excluded-redirects", + "installMode": "lazy", + "updateMode": "lazy", + "resources": { + "urls": [ "/**" ] + } } ] } diff --git a/src/app/app.config.ts b/src/app/app.config.ts index 19cebf7..557549e 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -7,8 +7,10 @@ import { provideAnimationsAsync } from '@angular/platform-browser/animations/asy import { provideServiceWorker } from '@angular/service-worker'; export const appConfig: ApplicationConfig = { - providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideClientHydration(withEventReplay()), provideAnimationsAsync('noop'), provideServiceWorker('ngsw-worker.js', { - enabled: !isDevMode(), - registrationStrategy: 'registerWhenStable:30000' + providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), + provideClientHydration(withEventReplay()), provideAnimationsAsync('noop'), + provideServiceWorker('ngsw-worker.js', { + enabled: !isDevMode(), + registrationStrategy: 'registerWhenStable:30000' })] };