]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
ui: Remove PWA navigate fallback to prevent caching API endpoint requests (#25174)
authorAleksander Grygier <redacted>
Wed, 1 Jul 2026 05:32:55 +0000 (07:32 +0200)
committerGitHub <redacted>
Wed, 1 Jul 2026 05:32:55 +0000 (07:32 +0200)
tools/ui/src/lib/constants/pwa.ts
tools/ui/tests/e2e/pwa.e2e.ts
tools/ui/tests/unit/pwa.spec.ts

index 80505fabdc5196f49af0e734efba332d70353df4..b9171d4bbffebf24d2f99534293e15ab117bb7a8 100644 (file)
@@ -288,9 +288,7 @@ export const API_CACHING_PATTERNS = {
 } as const;
 
 // SvelteKit PWA plugin options
-export const PWA_KIT_OPTIONS = {
-       NAVIGATE_FALLBACK: './'
-} as const;
+export const PWA_KIT_OPTIONS = {} as const;
 
 export const APPLE_META_TAGS = {
        MOBILE_WEB_APP_CAPABLE: { name: 'apple-mobile-web-app-capable', content: 'yes' },
@@ -322,6 +320,14 @@ export const SVELTEKIT_PWA_OPTIONS: SvelteKitPWAOptions = {
                globIgnores: GLOB_IGNORES,
                maximumFileSizeToCacheInBytes: CACHE_SETTINGS.MAX_FILE_SIZE_BYTES,
 
+               // Prevent @vite-pwa/sveltekit from auto-adding a NavigationRoute by
+               // setting navigateFallback to empty string. This keeps the service
+               // worker from intercepting direct browser navigation to server API
+               // endpoints (e.g. /slots, /models, /v1/models) which should return
+               // JSON, not the SPA HTML shell. The server's own static-file fallback
+               // handles non-API navigation to index.html for the SPA router.
+               navigateFallback: '',
+
                // Runtime caching for API calls - use NetworkFirst so APIs are always fresh
                runtimeCaching: [
                        {
@@ -351,10 +357,7 @@ export const SVELTEKIT_PWA_OPTIONS: SvelteKitPWAOptions = {
 
        devOptions: {
                enabled: true,
-               suppressWarnings: true,
-               // Use PWA_KIT_OPTIONS.NAVIGATE_FALLBACK to match production SW behaviour
-               // (navigateFallback defaults to the configured base path, which is '/' for this SPA).
-               navigateFallback: PWA_KIT_OPTIONS.NAVIGATE_FALLBACK
+               suppressWarnings: true
        },
 
        // SvelteKit-specific options
index e21672239b57e8573939678784d400049d84010f..c20eec276175dc25a48b4bf4eb5e22968b620087 100644 (file)
@@ -43,7 +43,10 @@ test.describe('PWA Service Worker', () => {
                expect(swContent).toMatch(/"_app\/immutable\/assets\/bundle\.[a-zA-Z0-9_-]+\.css"/);
                expect(swContent).toMatch(/"manifest\.webmanifest"/);
                expect(swContent).toMatch(/"_app\/version\.json"/);
-               expect(swContent).toMatch(/NavigationRoute/);
+               // NavigationRoute is intentionally absent — server API endpoints
+               // (e.g. /slots, /models) must not be intercepted by the PWA and
+               // should return JSON directly from the server.
+               expect(swContent).not.toMatch(/NavigationRoute/);
                expect(swContent).toMatch(/api-cache/);
        });
 
index 0059e246c3cd39e93c38c44408ffcaac7650e162..17da279866f23dd85bd3f423ab82bde2183a88b0 100644 (file)
@@ -108,9 +108,11 @@ describe('PWA Build Output', () => {
                        expect(swContent).toMatch(/"manifest\.webmanifest"/);
                });
 
-               it('has navigation route registered', () => {
+               it('no navigation route — API endpoints bypass PWA', () => {
                        expect(swContent).toBeTruthy();
-                       expect(swContent).toMatch(/NavigationRoute/);
+                       // NavigationRoute is intentionally absent so direct browser
+                       // navigation to server API endpoints returns JSON, not HTML.
+                       expect(swContent).not.toMatch(/NavigationRoute/);
                });
 
                it('has runtime caching for API routes', () => {