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:
@@ -66,8 +66,13 @@ startBrokerPoller()
|
|||||||
// Drain the D-05 outbox every 15s: dispatches pending CalDAV writes to Fastmail
|
// Drain the D-05 outbox every 15s: dispatches pending CalDAV writes to Fastmail
|
||||||
startOutboxWorker()
|
startOutboxWorker()
|
||||||
|
|
||||||
// Serve React PWA static assets from ./public (Vite build output)
|
// Serve React PWA static assets from ./public (Vite build output).
|
||||||
app.use('/assets/*', serveStatic({ root: './public' }))
|
// 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' }))
|
app.get('*', serveStatic({ path: './public/index.html' }))
|
||||||
|
|
||||||
// Only start the HTTP server when this module is run directly (not imported in tests)
|
// Only start the HTTP server when this module is run directly (not imported in tests)
|
||||||
|
|||||||
Reference in New Issue
Block a user