[object Object]

← back to Beverlyhillsbutler

server: 404-guard for .bak / .pre-* snapshot paths

23450ca33bebc897f117bc8c37efdf6d7ffb456c · 2026-05-19 17:29:24 -0700 · Steve Abrams

Hardens the static root so accidentally-deployed snapshot files never
serve. Pattern matches *.bak, *.bak.*, and any path containing .pre-.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit 23450ca33bebc897f117bc8c37efdf6d7ffb456c
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue May 19 17:29:24 2026 -0700

    server: 404-guard for .bak / .pre-* snapshot paths
    
    Hardens the static root so accidentally-deployed snapshot files never
    serve. Pattern matches *.bak, *.bak.*, and any path containing .pre-.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
 server.js | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/server.js b/server.js
index a8ee19c..fdad7b4 100644
--- a/server.js
+++ b/server.js
@@ -12,6 +12,14 @@ app.use((req, res, next) => {
   next();
 });
 
+// 404-guard: never serve snapshot/backup files even if one lands in public/
+app.use((req, res, next) => {
+  if (/\.(bak)(\..*)?$|\.pre-/i.test(req.path)) {
+    return res.status(404).send('Not found');
+  }
+  next();
+});
+
 app.use(express.static(path.join(__dirname, 'public')));
 
 app.get('/health', (req, res) => res.json({ status: 'ok', site: 'beverlyhillsbutler.com' }));

← a5293b1 gitignore: cover *.bak, *.bak.*, *.pre-* snapshot files  ·  back to Beverlyhillsbutler  ·  Add per-site favicon (kills /favicon.ico 404) 1802c8a →