← back to Mp3 Agentabrams
add 404-guard middleware so .bak/.pre-/~ snapshot paths never serve from static root
b6948f8de47007a7bf742ac3e6ba00ca6b71d1b4 · 2026-05-19 21:15:15 -0700 · SteveStudio2
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit b6948f8de47007a7bf742ac3e6ba00ca6b71d1b4
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date: Tue May 19 21:15:15 2026 -0700
add 404-guard middleware so .bak/.pre-/~ snapshot paths never serve from static root
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
server.js | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/server.js b/server.js
index c98a6db..ee41fc5 100644
--- a/server.js
+++ b/server.js
@@ -29,6 +29,15 @@ let manifest = loadManifest();
let byId = new Map(manifest.items.map((i) => [i.id, i]));
const app = express();
+
+// 404-guard: never serve snapshot/backup/editor cruft from static root even if
+// something slips past .gitignore (e.g. a *.bak left behind by a hot-edit).
+const SNAPSHOT_RE = /\.(bak|orig|rej|swp)(\.|$)|\.pre-|~$/i;
+app.use((req, res, next) => {
+ if (SNAPSHOT_RE.test(req.path)) return res.status(404).send('not found');
+ next();
+});
+
app.use(express.static(path.join(__dirname, 'public'), { extensions: ['html'] }));
app.get('/api/manifest', (_req, res) => {
← a0211fd broaden .gitignore to cover snapshot/backup/editor cruft
·
back to Mp3 Agentabrams
·
Add per-site favicon (kills /favicon.ico 404) d4839ec →