fix: corrections SW cache, nginx proxy, sw.js no-cache — 2026-05-01 05:48
This commit is contained in:
+14
-13
@@ -108,19 +108,20 @@ app.get('/api/health', (_req, res) => {
|
||||
// ─── Frontend statique (en production) ──────────────────────────────────────
|
||||
const frontendPath = path.join(__dirname, '..', 'public');
|
||||
if (fs.existsSync(frontendPath)) {
|
||||
app.use(express.static(frontendPath));
|
||||
// SPA fallback - toutes les routes non-API servent index.html
|
||||
app.get('*', (req, res) => {
|
||||
if (!req.path.startsWith('/api')) {
|
||||
res.sendFile(path.join(frontendPath, 'index.html'));
|
||||
}
|
||||
// Service worker — jamais mis en cache (sinon l'ancien SW continue après déploiement)
|
||||
app.get('/sw.js', (_req, res) => {
|
||||
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
|
||||
res.setHeader('Pragma', 'no-cache');
|
||||
res.setHeader('Expires', '0');
|
||||
res.sendFile(path.join(frontendPath, 'sw.js'));
|
||||
});
|
||||
}
|
||||
|
||||
// ─── Démarrage ───────────────────────────────────────────────────────────────
|
||||
app.listen(PORT, () => {
|
||||
console.log(`🚀 EquiTask API démarrée sur le port ${PORT}`);
|
||||
console.log(` Mode : ${process.env.NODE_ENV || 'development'}`);
|
||||
});
|
||||
// Manifeste PWA — pas de cache long
|
||||
app.get(/\.webmanifest$/, (_req, res, next) => {
|
||||
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
|
||||
res.setHeader('Expires', '0');
|
||||
next();
|
||||
});
|
||||
|
||||
export default app;
|
||||
app.use(express.static(frontendPath));
|
||||
// SPA fallback - toutes les routes non-API ser
|
||||
Reference in New Issue
Block a user