[object Object]

← back to Wallpaperestimator

Add 404-guard middleware for snapshot files; broaden .gitignore

491cd436e09461800d1db3df59c1827c8d07fbd6 · 2026-05-19 08:11:39 -0700 · Steve Abrams

Blocks .bak/.orig/.pre-/.swp/.tmp paths from serving via static
root, and ignores those snapshot patterns from git.

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

Files touched

Diff

commit 491cd436e09461800d1db3df59c1827c8d07fbd6
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue May 19 08:11:39 2026 -0700

    Add 404-guard middleware for snapshot files; broaden .gitignore
    
    Blocks .bak/.orig/.pre-/.swp/.tmp paths from serving via static
    root, and ignores those snapshot patterns from git.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
 .gitignore | 5 +++++
 server.js  | 8 ++++++++
 2 files changed, 13 insertions(+)

diff --git a/.gitignore b/.gitignore
index 1924158..da6e022 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,8 @@ tmp/
 dist/
 build/
 .next/
+*.bak
+*.bak.*
+*.pre-*
+*.orig
+*.swp
diff --git a/server.js b/server.js
index b63d614..2252968 100644
--- a/server.js
+++ b/server.js
@@ -20,6 +20,14 @@ app.use((req, res, next) => {
   next();
 });
 
+// 404-guard: never serve snapshot/backup files from the static root.
+app.use((req, res, next) => {
+  if (/\.(bak|orig|swp|tmp)$|\.bak\.|\.pre-/i.test(req.path)) {
+    return res.status(404).send('Not found');
+  }
+  next();
+});
+
 app.use(express.static(path.join(__dirname, 'public'), { extensions: ['html'] }));
 
 app.get('/healthz', (_req, res) => res.json({ ok: true, site: SITE, port: PORT }));

← 9925515 Replace dead /about nav link with #faq anchor to existing FA  ·  back to Wallpaperestimator  ·  add: pre-stage Meta Pixel snippet (placeholder; flip via _dw 6ccb9a5 →