From 70b60e9349c445fa88d30ba8ada73fc21bb85b02 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Thu, 30 May 2024 11:36:25 +0100 Subject: [PATCH] Allow SW scope without a trailing slash This is something of a compromise and requires a header. --- vite.config.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vite.config.ts b/vite.config.ts index f811307e1..f6e1008ff 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -93,6 +93,11 @@ export default defineConfig(({ mode }) => { VitePWA({ disable: !featurePwa, registerType: "autoUpdate", + // Remove the trailing slash so we can serve from e.g. /v/3 not just /v/3/ + // This requires the corresponding service-worker-allowed header to be set. + // URLs are prefix matched so it's a compromise solution that could affect other + // paths sharing the same prefix + scope: process.env.BASE_URL.replace(/\/$/, ""), workbox: { cacheId: pwaCacheId, // Only precache language assets for the fallback language.