onlinemodus fix failed

This commit is contained in:
2026-11-19 00:55:39 +01:00
parent 64c5b65543
commit 347701d66f
10 changed files with 414 additions and 53 deletions

View File

@@ -72,7 +72,14 @@ app.delete(/^\/db\/(.*)\.json$/, (req, res) => {
});
// --- static game (same origin: no CORS, no mixed content) ------------------------------------------
app.use(express.static(path.join(__dirname, '..', 'game')));
app.use(express.static(path.join(__dirname, '..', 'game'), {
etag: true,
setHeaders(res, p) {
// images / fonts / audio rarely change -> cache hard (fast re-renders, no re-fetch flicker)
if (/\.(png|jpe?g|webp|gif|svg|woff2?|ttf|otf|mp3|ogg|wav|m4a)$/i.test(p)) res.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
else res.setHeader('Cache-Control', 'no-cache'); // code/html: revalidate so deploys show up
},
}));
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => console.log('Robot Clash server on :' + PORT));