← back to Visual Factory
refactor: add .bak/.pre-/.orig 404 guard + broaden .gitignore snapshot patterns
26fb67d7e01fa2271c97ba86cdfcc81c085a214a · 2026-05-19 17:25:40 -0700 · Steve
Express middleware now hard-404s any request for snapshot artifacts before
the static handler can serve them. .gitignore picks up the same patterns so
auto-gitify won't sweep them into the repo.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit 26fb67d7e01fa2271c97ba86cdfcc81c085a214a
Author: Steve <steve@designerwallcoverings.com>
Date: Tue May 19 17:25:40 2026 -0700
refactor: add .bak/.pre-/.orig 404 guard + broaden .gitignore snapshot patterns
Express middleware now hard-404s any request for snapshot artifacts before
the static handler can serve them. .gitignore picks up the same patterns so
auto-gitify won't sweep them into the repo.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
.gitignore | 7 +++++++
server.js | 10 ++++++++++
2 files changed, 17 insertions(+)
diff --git a/.gitignore b/.gitignore
index f7df9b5..19f3777 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,10 @@ tmp/
dist/
build/
.next/
+
+# Snapshot/backup artifacts (standing fleet-refactor rule 2026-05-19)
+*.bak
+*.bak.*
+*.pre-*
+*.orig
+*~
diff --git a/server.js b/server.js
index a86da6e..6652379 100644
--- a/server.js
+++ b/server.js
@@ -69,6 +69,16 @@ app.use((req, res, next) => {
// Kept commented as a record of the prior split-port architecture.
// app.use((req, res, next) => { res.set('Access-Control-Allow-Origin','*'); ... });
+// Block snapshot/backup artifacts from ever serving off static root (standing
+// fleet-refactor rule). Catches `.bak`, `.bak.<anything>`, `.pre-<anything>`,
+// `.orig`, and `~`-suffixed editor backups anywhere in the URL path.
+app.use((req, res, next) => {
+ if (/(\.bak(\..*)?|\.pre-[^/]*|\.orig|~)(\?|$)/i.test(req.path)) {
+ return res.status(404).type('text/plain').send('not found');
+ }
+ next();
+});
+
// Serve the static UI (public/index.html etc.) at the orchestrator root. This
// collapses the previous 9892 (API) + 9893 (UI) split into a single port.
app.use(express.static(path.join(__dirname, 'public')));
← 73b0163 snapshot: 9 file(s) changed, +3 new, ~6 modified
·
back to Visual Factory
·
(newest)