···431431 res.sendFile(path.join(distPath, 'sw.js'));
432432});
433433434434-app.use(express.static(distPath));
434434+// HTML must never be HTTP-cached — ensures SW networkFirst gets fresh content on every deploy.
435435+// express.static serves /index.html, /docs/index.html etc. BEFORE the SPA fallback routes,
436436+// so we must set no-cache headers here too (not just on the fallback routes).
437437+const htmlNoCacheHeaders = { 'Cache-Control': 'no-cache, no-store, must-revalidate' };
435438436436-// HTML pages must not be HTTP-cached — ensures SW networkFirst fetch gets fresh content
437437-const htmlNoCacheHeaders = { 'Cache-Control': 'no-cache, no-store, must-revalidate' };
439439+app.use(express.static(distPath, {
440440+ setHeaders: (res, filePath) => {
441441+ if (filePath.endsWith('.html')) {
442442+ res.set(htmlNoCacheHeaders);
443443+ }
444444+ },
445445+}));
438446439447// SPA fallback: serve the correct index.html for each sub-app
440448app.get('/docs/:id', (_req: Request, res: Response) => { res.set(htmlNoCacheHeaders); res.sendFile(path.join(distPath, 'docs/index.html')); });