[object Object]

← back to Fashion Style Guides

add .bak/.pre- 404-guard middleware + broaden .gitignore

f5ecce28b5b21a04ede8c0601b8cdfae03db16b2 · 2026-05-19 15:19:12 -0700 · SteveStudio2

Prevents snapshot/backup files from leaking via the static root and keeps
them out of the repo by default.

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

Files touched

Diff

commit f5ecce28b5b21a04ede8c0601b8cdfae03db16b2
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date:   Tue May 19 15:19:12 2026 -0700

    add .bak/.pre- 404-guard middleware + broaden .gitignore
    
    Prevents snapshot/backup files from leaking via the static root and keeps
    them out of the repo by default.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
 .gitignore | 4 ++++
 server.js  | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/.gitignore b/.gitignore
index a027f95..9cb7b9d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,7 @@ dist/
 build/
 .next/
 data/cache/
+*.bak
+*.bak.*
+*.pre-*
+*~
diff --git a/server.js b/server.js
index 11e07ef..4ec4c72 100644
--- a/server.js
+++ b/server.js
@@ -8,6 +8,15 @@ const DATA_DIR = path.join(ROOT, 'data');
 
 const app = express();
 app.use(express.json({ limit: '1mb' }));
+
+// 404-guard — never serve snapshot/backup files even if they accidentally land in public/
+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(ROOT, 'public')));
 
 const loadJson = (file) => JSON.parse(fs.readFileSync(path.join(DATA_DIR, file), 'utf8'));

← 8f373f2 initial scaffold — 20 fashion houses + pantone (coty/fashion  ·  back to Fashion Style Guides  ·  Add per-site favicon (kills /favicon.ico 404) a3177e9 →