← back to Cncp Failures Mockups
Block .bak/.pre- snapshot artifacts from static serving + gitignore
c0aa565c35f2c340c6981f1803c62c9706e77b14 · 2026-05-19 17:32:21 -0700 · SteveStudio2
- Broadens .gitignore to cover editor/build snapshots (*.bak, *.bak.*,
*.pre-*, *.swp, tmp/, dist/, build/, .next/) so accidental snapshots
never enter the repo.
- Adds an Express middleware 404-guard before express.static so any
.bak / .pre- / .swp path returns 404 even if a snapshot slips into
public/ on disk.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit c0aa565c35f2c340c6981f1803c62c9706e77b14
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date: Tue May 19 17:32:21 2026 -0700
Block .bak/.pre- snapshot artifacts from static serving + gitignore
- Broadens .gitignore to cover editor/build snapshots (*.bak, *.bak.*,
*.pre-*, *.swp, tmp/, dist/, build/, .next/) so accidental snapshots
never enter the repo.
- Adds an Express middleware 404-guard before express.static so any
.bak / .pre- / .swp path returns 404 even if a snapshot slips into
public/ on disk.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
.gitignore | 10 ++++++++++
server.js | 10 ++++++++++
2 files changed, 20 insertions(+)
diff --git a/.gitignore b/.gitignore
index 0d22d4b..ae2f233 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,5 +3,15 @@ node_modules/
.DS_Store
audio-cache/
+# Editor / build / snapshot artifacts — never commit
+*.bak
+*.bak.*
+*.pre-*
+*.swp
+tmp/
+dist/
+build/
+.next/
+
# Secrets — never commit
.env*
diff --git a/server.js b/server.js
index 7f37dbc..eebbef4 100644
--- a/server.js
+++ b/server.js
@@ -45,6 +45,16 @@ const AUDIO_CACHE = path.join(__dirname, 'audio-cache');
fs.mkdirSync(AUDIO_CACHE, { recursive: true });
const app = express();
+
+// 404-guard — never serve editor/build snapshot artifacts even if one accidentally
+// lands under public/. Catches *.bak, *.bak.*, *.pre-*, *.swp paths anywhere in the URL.
+app.use((req, res, next) => {
+ if (/\.(bak|swp)(\.|$|\/)/i.test(req.path) || /\.pre-/i.test(req.path)) {
+ return res.status(404).type('text/plain').send('Not found');
+ }
+ next();
+});
+
app.use(express.static(path.join(__dirname, 'public')));
// GET /data
← 2fdc877 Add noreferrer to "Open in new tab" link
·
back to Cncp Failures Mockups
·
add: pre-stage Meta Pixel snippet (placeholder; flip via _dw dec04b6 →