From c10b8f6ee07dd6e4d32e652f95dbe6bae706a1df Mon Sep 17 00:00:00 2001 From: Pagwin Date: Thu, 4 Sep 2025 16:51:25 -0400 Subject: [PATCH] hacky workaround --- static/demos/light-dark-demo-4/index.html | 7 +++++-- static/demos/light-dark-demo-4/sw.js | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/static/demos/light-dark-demo-4/index.html b/static/demos/light-dark-demo-4/index.html index 42cc164..5297d75 100644 --- a/static/demos/light-dark-demo-4/index.html +++ b/static/demos/light-dark-demo-4/index.html @@ -76,7 +76,7 @@ -

Don't copy this code at all, it is for demo purposes only and is terrible code. Note: if you +

Don't copy this code at all, it is for demo purposes only and is terrible code.
Note: if + you hard refresh you will get your system preference of light/dark due to this demo being powered by a service worker

+
+
diff --git a/static/demos/light-dark-demo-4/sw.js b/static/demos/light-dark-demo-4/sw.js index c4960f5..3fd6276 100644 --- a/static/demos/light-dark-demo-4/sw.js +++ b/static/demos/light-dark-demo-4/sw.js @@ -19,9 +19,9 @@ self.addEventListener("fetch", event =>{ }) async function handle_redirect(req){ - const go_back_to = req.headers.get('Referer') || '/';; - console.log("ref:",req.headers.get('Referer'), go_back_to); - console.log('All headers:', [...req.headers.entries()]); + const url = new URL(event.request.url); + const go_back_to = url.searchParams.get('ref') ?? '/'; + console.log("ref:",url.searchParams.get('ref'), go_back_to); const db_req = self.indexedDB.open("light-dark-store");