From 30c644a8ec6d573223bf82a619ca3c18a0fc7f68 Mon Sep 17 00:00:00 2001 From: Scott Pouliot Date: Wed, 20 May 2026 22:48:31 -0400 Subject: [PATCH] Fix service worker TypeError on localhost; inline edit config timing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sw.js: Remove fetch event interception entirely. The passthrough e.respondWith(fetch(request)) call was throwing TypeError on localhost HTTPS due to certificate trust differences in the SW context, causing JS/CSS resource loads to fail. The SW exists for PWA installability only — no interception is needed to satisfy that requirement. inline-item-edit.js: Move window.inlineItemEdit config read inside DOMContentLoaded so script load order vs. config assignment in @section Scripts doesn't matter. Co-Authored-By: Claude Sonnet 4.6 --- src/PowderCoating.Web/wwwroot/sw.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/PowderCoating.Web/wwwroot/sw.js b/src/PowderCoating.Web/wwwroot/sw.js index 2ce4a66..abd657d 100644 --- a/src/PowderCoating.Web/wwwroot/sw.js +++ b/src/PowderCoating.Web/wwwroot/sw.js @@ -12,15 +12,7 @@ const SKIP_PREFIXES = ['/hubs/', '/Kiosk/PollSession']; self.addEventListener('install', () => self.skipWaiting()); self.addEventListener('activate', e => e.waitUntil(self.clients.claim())); -self.addEventListener('fetch', e => { - const url = new URL(e.request.url); - - // Always skip cross-origin requests - if (url.origin !== self.location.origin) return; - - // Skip SignalR hubs and kiosk polling — let the browser handle these directly - if (SKIP_PREFIXES.some(p => url.pathname.startsWith(p))) return; - - // Passthrough: no caching, no modification - e.respondWith(fetch(e.request)); -}); +// No fetch interception — all requests handled natively by the browser. +// The SW exists solely for PWA installability; calling e.respondWith(fetch(request)) +// causes TypeError failures on localhost HTTPS due to certificate trust differences +// in the SW context, breaking JS/CSS resource loads.