Server-side printing, roll type setting, cache headers

This commit is contained in:
2026-09-07 11:06:19 +10:00
parent 28b52145eb
commit 8bc71792e3
3 changed files with 46 additions and 1 deletions
+13 -1
View File
@@ -72,7 +72,19 @@ app.get('/admin/login', (req, res) => {
// Nobody should land on the raw filenames; keep one address per page.
app.get(['/admin.html', '/login.html'], (req, res) => res.redirect('/admin'));
app.use(express.static(publicDir, { extensions: ['html'], index: false }));
// no-cache still allows a 304 on an unchanged file, but forces the browser to ask
// first. Without it a cached admin.js survives an upgrade and the console keeps
// running yesterday's code against today's server, which is impossible to diagnose
// from the outside.
app.use(
express.static(publicDir, {
extensions: ['html'],
index: false,
setHeaders: (res, filePath) => {
if (/\.(html|js|css)$/.test(filePath)) res.setHeader('Cache-Control', 'no-cache');
},
})
);
app.get('/favicon.ico', (req, res) => res.redirect(301, '/favicon.svg'));
app.use((req, res) => res.status(404).sendFile(path.join(publicDir, 'index.html')));