fix: corrections SW cache, nginx proxy, sw.js no-cache — 2026-05-01 05:48

This commit is contained in:
Claude Deploy
2026-05-01 05:48:38 +00:00
parent 5dc52a0413
commit 16820c5c14
9 changed files with 25 additions and 48 deletions
+1 -3
View File
@@ -34,6 +34,4 @@
"@types/uuid": "^10.0.0",
"drizzle-kit": "^0.22.7",
"ts-node-dev": "^2.0.0",
"typescript": "^5.4.5"
}
}
"typescript": "^5.4
+11 -9
View File
@@ -47,13 +47,15 @@ app.use('/api/export', exportRouter)
// ─── Serve Frontend (production) ─────────────────────────────────────────────
const publicDir = path.join(__dirname, '..', 'public')
if (fs.existsSync(publicDir)) {
app.use(express.static(publicDir))
app.get('*', (_req, res) => res.sendFile(path.join(publicDir, '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(publicDir, 'sw.js'))
})
// ─── Start ────────────────────────────────────────────────────────────────────
app.listen(PORT, () => {
console.log(`✓ ShootTracker backend → http://localhost:${PORT}`)
console.log(` Uploads : ${UPLOADS_DIR}`)
console.log(` AI : ${process.env.AI_SERVICE_URL || 'http://localhost:8000'}`)
})
// Manifeste PWA — pas de cache long
app.get(/\.webmanifest$/, (_req, res, next) => {
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate')
res.set
+1 -2
View File
@@ -168,5 +168,4 @@ exportRouter.get('/excel', (req: AuthRequest, res) => {
const filename = `shoottracker_${format(new Date(), 'yyyy-MM-dd')}.xlsx`
res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
res.setHeader('Content-Disposition', `attachment; filename="${filename}"`)
res.send(XLSX.write(wb, { type: 'buffer', bookType: 'xlsx' }))
})
res.send(XLSX.write(wb, { type: 'buffer', bookType:
-1
View File
@@ -16,4 +16,3 @@
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}