fix(api): serve the full ./public tree, not just /assets/*

Root-level PWA files (manifest.webmanifest, sw.js, registerSW.js, workbox-*.js,
icon-*.png, apple-touch-icon.png) were falling through to the index.html
catch-all and returning HTML — breaking the manifest (syntax error) and
preventing the service worker from ever registering. serveStatic('/*') serves
any existing file and calls next() for SPA routes, so index.html stays the
fallback. Registered after /health, /api/*, /callback so those still win.
This commit is contained in:
Lucas Berger
2026-06-06 21:57:42 -04:00
parent 1adb460412
commit 431ab31fb8
+7 -2
View File
@@ -66,8 +66,13 @@ startBrokerPoller()
// Drain the D-05 outbox every 15s: dispatches pending CalDAV writes to Fastmail
startOutboxWorker()
// Serve React PWA static assets from ./public (Vite build output)
app.use('/assets/*', serveStatic({ root: './public' }))
// Serve React PWA static assets from ./public (Vite build output).
// MUST serve the whole ./public tree, not just /assets/* — root-level PWA files
// (manifest.webmanifest, sw.js, registerSW.js, workbox-*.js, icon-*.png,
// apple-touch-icon.png) live at the root. serveStatic calls next() when a file
// is not found, so SPA routes fall through to the index.html catch-all below.
// (Registered AFTER /health, /api/*, and /callback, so those win.)
app.use('/*', serveStatic({ root: './public' }))
app.get('*', serveStatic({ path: './public/index.html' }))
// Only start the HTTP server when this module is run directly (not imported in tests)