Fix SW excluding all /_* paths, breaking SvelteKit nsites

The fetch event handler was skipping all paths starting with `/_`,
intended to protect iframe-fetch-client system files. But this also
excluded SvelteKit asset paths like `/_app/immutable/chunks/*.js`,
causing them to bypass JSON-RPC and hit the network directly, which
returns HTML instead of JavaScript.

Narrow the exclusion to only `/_iframe-client/` — the specific
prefix used by the iframe-fetch-client's own assets.
This commit is contained in:
Alex Gleason committed 2026-04-03 18:58:24 -05:00
1 parent 46fefd5352
commit 63671ea85b
1 file changed
+3 -11
+3 -11
View File
@@ -138,18 +138,10 @@ self.addEventListener("fetch", (event) => {
return;
}
// Let iframe client system files be handled normally
if (url.pathname.startsWith("/_") || url.pathname === "/sw.js") {
return;
}
// Let root path be handled normally (loads the iframe client page)
if (url.pathname === "/") {
return;
}
// Let iframe client assets be handled normally (anything in _iframe-client directory and common assets)
// Let iframe client system files and common assets be handled normally
if (url.pathname.startsWith("/_iframe-client/") ||
url.pathname === "/sw.js" ||
url.pathname === "/" ||
url.pathname === "/favicon.ico" ||
url.pathname === "/manifest.webmanifest") {
return;