Skip to content

Commit 5171377

Browse files
Allow SW scope without a trailing slash (#1184)
This is something of a compromise and requires a header.
1 parent 340e5bb commit 5171377

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

vite.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ export default defineConfig(({ mode }) => {
9393
VitePWA({
9494
disable: !featurePwa,
9595
registerType: "autoUpdate",
96+
// Remove the trailing slash so we can serve from e.g. /v/3 not just /v/3/
97+
// This requires the corresponding service-worker-allowed header to be set.
98+
// URLs are prefix matched so it's a compromise solution that could affect other
99+
// paths sharing the same prefix
100+
scope: process.env.BASE_URL?.replace(/\/$/, ""),
96101
workbox: {
97102
cacheId: pwaCacheId,
98103
// Only precache language assets for the fallback language.

0 commit comments

Comments
 (0)