mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-27 13:48:51 +08:00
26 lines
750 B
JavaScript
26 lines
750 B
JavaScript
// sw.js
|
|
self.addEventListener("install", () => self.skipWaiting());
|
|
self.addEventListener("activate", e => e.waitUntil(self.clients.claim()));
|
|
self.addEventListener("fetch", e => {
|
|
if (e.request.mode != 'navigate' &&
|
|
!e.request.url.includes(".worker.js")) {
|
|
return;
|
|
}
|
|
|
|
e.respondWith((async () => {
|
|
const response = await fetch(e.request);
|
|
|
|
const newHeaders = new Headers(response.headers);
|
|
newHeaders.set("Cross-Origin-Embedder-Policy", "require-corp");
|
|
newHeaders.set("Cross-Origin-Opener-Policy", "same-origin");
|
|
|
|
const moddedResponse = new Response(response.body, {
|
|
status: response.status,
|
|
statusText: response.statusText,
|
|
headers: newHeaders,
|
|
});
|
|
|
|
return moddedResponse;
|
|
})());
|
|
});
|