fix: guard service worker cache.put against non-http(s) schemes; correct docs to match actual nginx domain mapping

This commit is contained in:
2026-09-27 19:56:34 +03:30
parent b01da2e04e
commit 112b196809
3 changed files with 15 additions and 12 deletions
+2 -1
View File
@@ -24,13 +24,14 @@ self.addEventListener("fetch", (event) => {
const url = new URL(event.request.url);
if (event.request.method !== "GET") return;
if (!url.protocol.startsWith("http")) return;
if (url.pathname.startsWith("/api")) return;
event.respondWith(
fetch(event.request)
.then((res) => {
const resClone = res.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(event.request, resClone));
caches.open(CACHE_NAME).then((cache) => cache.put(event.request, resClone).catch(() => {}));
return res;
})
.catch(() => caches.match(event.request))