fix: add origin check to sw.js to prevent cross-origin caching

This commit is contained in:
posimai 2026-03-17 17:26:38 +09:00
parent 4f94c18f02
commit 7ad2c300af
1 changed files with 2 additions and 0 deletions

2
sw.js
View File

@ -19,7 +19,9 @@ self.addEventListener('activate', event => {
self.clients.claim(); self.clients.claim();
}); });
const ORIGIN = self.location.origin;
self.addEventListener('fetch', event => { self.addEventListener('fetch', event => {
if (!event.request.url.startsWith(ORIGIN)) return;
const url = new URL(event.request.url); const url = new URL(event.request.url);
// API: network first, fallback to cache // API: network first, fallback to cache