Fix redirects broken by service worker navigate fallback; v1.1.31

The SW's navigateFallback was using a denylist, so any path not explicitly
excluded (e.g. /spotify, /apple, /amazon, custom admin redirects) got served
the cached index.html instead of reaching the server's redirect handler.

Switch to navigateFallbackAllowlist: the SW only intercepts known SPA routes;
all other paths hit the network so server-side 301/302 redirects work correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nmemmert
2026-08-10 08:49:15 -04:00
parent c56e468115
commit 76239ee83b
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "siteforge", "name": "siteforge",
"private": true, "private": true,
"version": "1.1.30", "version": "1.1.31",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
+9 -1
View File
@@ -23,7 +23,15 @@ export default defineConfig({
}, },
workbox: { workbox: {
navigateFallback: '/index.html', navigateFallback: '/index.html',
navigateFallbackDenylist: [/^\/api\//, /^\/feed\.xml/, /^\/uploads\//], // Allowlist-only approach: SW only serves index.html for known SPA routes.
// Everything else (admin-configured redirects, /spotify, /apple, /amazon,
// feed.xml, robots.txt, etc.) goes to the server so server-side redirects work.
navigateFallbackAllowlist: [
/^\/$/, // exact root
/^\/(start-here|about|contact|resources|thanks|preview|privacy|terms|salvation)(\/.*)?$/,
/^\/(study|studys|episodes|finished|downloads|subscribe|certificate)(\/.*)?$/,
/^\/(questions|admin|email|contacts|calendar)(\/.*)?$/,
],
runtimeCaching: [ runtimeCaching: [
{ {
urlPattern: /^\/api\/(episodes|questions)/, urlPattern: /^\/api\/(episodes|questions)/,