From 16c8651cdb07e92ca2760ef32b3cc8dba7c749b4 Mon Sep 17 00:00:00 2001 From: everyx Date: Thu, 23 Mar 2023 23:27:00 +0800 Subject: [PATCH] fix: infinite refreshing when host at subpath Close: #751 --- src/swRegistration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/swRegistration.ts b/src/swRegistration.ts index 927cba6..a2d0622 100644 --- a/src/swRegistration.ts +++ b/src/swRegistration.ts @@ -23,7 +23,7 @@ export function register(config?: Config) { } window.addEventListener('load', () => { - const swUrl = `./sw.js`; + const swUrl = new URL('sw.js', publicUrl.href).href; if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not.