[object Object]

← back to Wallpaperwednesday

Block snapshot-file paths from static root + ignore *.bak/*.pre-*

3912377d64d898bce69889d63953f060d290fadc · 2026-05-19 08:08:51 -0700 · Steve Abrams

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

Files touched

Diff

commit 3912377d64d898bce69889d63953f060d290fadc
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue May 19 08:08:51 2026 -0700

    Block snapshot-file paths from static root + ignore *.bak/*.pre-*
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
 .gitignore | 5 +++++
 server.js  | 9 +++++++++
 2 files changed, 14 insertions(+)

diff --git a/.gitignore b/.gitignore
index fc59ee5..e53727c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,8 @@ tmp/
 dist/
 build/
 data/subscribers.jsonl
+*.bak
+*.bak.*
+*.pre-*
+*~
+*.orig
diff --git a/server.js b/server.js
index 47be9f7..e56aa9e 100644
--- a/server.js
+++ b/server.js
@@ -6,6 +6,15 @@ const app = express();
 const PORT = process.env.PORT || 9900;
 
 app.use(express.json());
+
+// Guard: never serve editor/snapshot artifacts (.bak / .pre-* / *~ / .orig) from static root.
+app.use((req, res, next) => {
+  if (/\.bak$|\.bak\.|\.pre-|\.orig$|~$/i.test(req.path)) {
+    return res.status(404).send('Not found');
+  }
+  next();
+});
+
 app.use(express.static(path.join(__dirname, 'public')));
 
 const products = JSON.parse(fs.readFileSync(path.join(__dirname, 'data/products.json'), 'utf8'));

← 85f9050 Add noreferrer to all target=_blank external links  ·  back to Wallpaperwednesday  ·  add corner-nav.js — universal top-right nav per _shared/corn 7298d1b →