summaryrefslogtreecommitdiff
path: root/apps/web/app/sw.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-07 23:44:08 -0800
committerFuwn <[email protected]>2026-02-07 23:44:08 -0800
commit6023d5fb984b94687eca7997043e534bfaf97a26 (patch)
tree7c6f5a3d5cd0f15239f1b3f4681e10f249972b7a /apps/web/app/sw.ts
parentfix: move vercel.json into apps/web for monorepo install resolution (diff)
downloadasa.news-6023d5fb984b94687eca7997043e534bfaf97a26.tar.xz
asa.news-6023d5fb984b94687eca7997043e534bfaf97a26.zip
fix: service worker passes cross-origin requests through to network
Prevents no-response errors on redirected cross-origin fetches like Google favicon service by prepending a NetworkOnly rule for all non-same-origin requests.
Diffstat (limited to 'apps/web/app/sw.ts')
-rw-r--r--apps/web/app/sw.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/apps/web/app/sw.ts b/apps/web/app/sw.ts
index 894c9ae..fa2a8b7 100644
--- a/apps/web/app/sw.ts
+++ b/apps/web/app/sw.ts
@@ -1,7 +1,7 @@
/// <reference lib="webworker" />
import { defaultCache } from "@serwist/next/worker"
import type { PrecacheEntry, SerwistGlobalConfig } from "serwist"
-import { Serwist } from "serwist"
+import { Serwist, NetworkOnly } from "serwist"
declare global {
interface WorkerGlobalScope extends SerwistGlobalConfig {
@@ -16,7 +16,13 @@ const serwist = new Serwist({
skipWaiting: true,
clientsClaim: true,
navigationPreload: true,
- runtimeCaching: defaultCache,
+ runtimeCaching: [
+ {
+ matcher: ({ url }) => url.origin !== self.location.origin,
+ handler: new NetworkOnly(),
+ },
+ ...defaultCache,
+ ],
})
serwist.addEventListeners()