Public Access
Server-side printing, roll type setting, cache headers
This commit is contained in:
+13
-1
@@ -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')));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user