[object Object]

← back to Wallpaperdistributors

harden: ignore snapshot files + 404-guard .bak/.pre- in static root

bb12e91d530140c074973fd0b81daed05eaf9d04 · 2026-05-19 08:11:48 -0700 · Steve Abrams

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

Files touched

Diff

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

    harden: ignore snapshot files + 404-guard .bak/.pre- in static root
    
    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 4a0b3ea..20d9cc5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,8 @@ tmp/
 dist/
 build/
 .next/
+*.bak
+*.bak.*
+*.pre-*
+*.orig
+*~
diff --git a/server.js b/server.js
index a45e9d2..6a5c827 100644
--- a/server.js
+++ b/server.js
@@ -28,6 +28,14 @@ app.use((req, res, next) => {
   next();
 });
 
+// Never serve editor/snapshot artifacts from the static root.
+app.use((req, res, next) => {
+  if (/\.(bak|orig|pre-[^/]*|[^/]*~)$|\.bak\.|\.pre-/i.test(req.path)) {
+    return res.status(404).render('404', { site: SITE });
+  }
+  next();
+});
+
 app.use(express.static(path.join(__dirname, 'public'), { maxAge: '1h' }));
 
 const allRegions = Array.from(new Set(distributors.flatMap(d => d.regions))).sort();

← e248367 a11y: add rel=noreferrer to external _blank links on distrib  ·  back to Wallpaperdistributors  ·  Add per-site favicon (kills /favicon.ico 404) ae37058 →