← back to Wallpapercanada
server: 404-guard for snapshot paths + facets total counts the served list
2ee110e77439f66d8494403fd2b94f2a4371bddd · 2026-05-19 08:14:58 -0700 · Steve Abrams
Added middleware that 404s any .bak / .pre-* request before express.static so leftover snapshot files can never serve from the static root. /api/facets total now reports PRODUCTS_NICHE.length (the list actually served) instead of the raw pre-niche-filter PRODUCTS.length.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit 2ee110e77439f66d8494403fd2b94f2a4371bddd
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Tue May 19 08:14:58 2026 -0700
server: 404-guard for snapshot paths + facets total counts the served list
Added middleware that 404s any .bak / .pre-* request before express.static so leftover snapshot files can never serve from the static root. /api/facets total now reports PRODUCTS_NICHE.length (the list actually served) instead of the raw pre-niche-filter PRODUCTS.length.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
server.js | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/server.js b/server.js
index d88045f..8ab643d 100644
--- a/server.js
+++ b/server.js
@@ -137,6 +137,14 @@ app.use(express.json({ limit: '256kb' }));
require('./_universal-contact')(app, { siteName: "Wallpaper Canada", zdColor: "#d4a847", zdPosition: 'right' });
require('./_universal-auth')(app, { siteName: "wallpapercanada" });
+// Guard: never serve editor snapshot files (*.bak, *.bak.*, *.pre-*) from static root.
+app.use((req, res, next) => {
+ if (/(^|\.)bak(\.|$)|\.pre-/i.test(req.path)) {
+ return res.status(404).send('Not found');
+ }
+ next();
+});
+
app.use(express.static(path.join(__dirname, 'public')));
app.get('/api/products', (req, res) => {
@@ -173,7 +181,7 @@ app.get('/api/facets', (req, res) => {
aesthetics[p.aesthetic] = (aesthetics[p.aesthetic] || 0) + 1;
vendors[p.vendor] = (vendors[p.vendor] || 0) + 1;
}
- res.json({ aesthetics, vendors, total: PRODUCTS.length });
+ res.json({ aesthetics, vendors, total: PRODUCTS_NICHE.length });
});
app.get('/api/health', (req, res) => res.json({ status: 'ok', count: PRODUCTS_NICHE.length, dropped: DROPPED }));
← 56a7fe7 chore: untrack 18 editor snapshot files (*.bak / *.pre-*) an
·
back to Wallpapercanada
·
nav: remove dead /about links (3) — no About page or route e abe9213 →