fix: add origin check to sw.js to prevent cross-origin caching
This commit is contained in:
parent
4f94c18f02
commit
7ad2c300af
2
sw.js
2
sw.js
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue