This commit is contained in:
Pagwin 2025-09-04 16:24:15 -04:00
parent 6c779d54f2
commit 4bde55ad64

View file

@ -1,18 +1,17 @@
// Cannot use Set-Cookie header for security reasons, use IndexedDB instead
self.addEventListener("fetch", event =>{
const url = new URL(event.request.url);
if(url.pathname.endsWith(".css")) return;
//TODO: make an endpoint to set the localStorage up then set the form to go to there and have it HTTP 302 or 307 with handle_html for html responses and handle_redirect for the other case
event.respondWith((async ()=>{
const resp = await fetch(event.request);
const resp2 = resp.clone();
const resp3 = resp2.clone();
const body = await resp2.text();
const url = new URL(event.request.url);
if(url.pathname.endsWith("light-dark-toggle")){
return await handle_redirect(event.request);
}
else if(url.hostname !== "pagwin.xyz") return;
else {
return await handle_html(event.request, resp3, body);
}