← back to Pitch Guard
Add 404-guard middleware so .bak/.pre- snapshot files never serve from static root
88b1ce4bacc666796157d9e474c124a43f1959c1 · 2026-05-19 17:33:47 -0700 · SteveStudio2
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit 88b1ce4bacc666796157d9e474c124a43f1959c1
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date: Tue May 19 17:33:47 2026 -0700
Add 404-guard middleware so .bak/.pre- snapshot files never serve from static root
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
server.js | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/server.js b/server.js
index bf577e8..dd2337f 100644
--- a/server.js
+++ b/server.js
@@ -27,6 +27,16 @@ try {
const app = express();
app.use(express.json({ limit: '4mb' }));
+
+// 404-guard: never serve snapshot/backup files even if one accidentally lands in public/.
+// Matches *.bak / *.bak.* / *.pre-* anywhere in the path.
+app.use((req, res, next) => {
+ if (/\.(bak)(\.|$)|\/\.pre-|\.pre-/i.test(req.path)) {
+ return res.status(404).type('text/plain').send('Not found');
+ }
+ next();
+});
+
app.use(express.static(path.join(__dirname, 'public')));
const PORT = process.env.PORT || 8123;
← b193fc5 Add rel=noreferrer to target=_blank link (mechanical safety
·
back to Pitch Guard
·
Broaden .gitignore to exclude .bak / .pre- snapshot files e610e4d →