Skip to content

Commit

Permalink
Allow SW scope without a trailing slash
Browse files Browse the repository at this point in the history
This is something of a compromise and requires a header.
  • Loading branch information
microbit-matt-hillsdon committed May 30, 2024
1 parent 340e5bb commit 70b60e9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 70b60e9

Please sign in to comment.