← back to Vinylwallpaper
fix facets total, add clean-URL routes + bak-file 404 guard
dd74a8d538da4eaa5cd27bd55c51c7d979b0d244 · 2026-05-19 07:52:52 -0700 · Steve Abrams
- /api/facets total now counts PRODUCTS_NICHE (the filtered list
actually served) instead of the raw unfiltered PRODUCTS array.
- Added clean-URL routes for /about /history /care /trade /sourcing
so the extension-less nav links resolve instead of 404ing.
- Added Express middleware that 404s any .bak / .pre- path before
the static handler, so snapshot files never serve from public/.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit dd74a8d538da4eaa5cd27bd55c51c7d979b0d244
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Tue May 19 07:52:52 2026 -0700
fix facets total, add clean-URL routes + bak-file 404 guard
- /api/facets total now counts PRODUCTS_NICHE (the filtered list
actually served) instead of the raw unfiltered PRODUCTS array.
- Added clean-URL routes for /about /history /care /trade /sourcing
so the extension-less nav links resolve instead of 404ing.
- Added Express middleware that 404s any .bak / .pre- path before
the static handler, so snapshot files never serve from public/.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
server.js | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/server.js b/server.js
index 185fc26..93a2bb2 100644
--- a/server.js
+++ b/server.js
@@ -134,6 +134,21 @@ app.use(express.json({ limit: "256kb" }));
const cfg = require('../_shared/site-config').load(__dirname);
require("./_universal-contact")(app, cfg.contact);
require("./_universal-auth")(app, cfg.auth);
+
+// Security guard: never serve snapshot/backup files from the static root.
+app.use((req, res, next) => {
+ if (/\.(bak|pre-[^/]*)$|\.bak(\.|$)|\.pre-/i.test(req.path)) {
+ return res.status(404).send('Not found');
+ }
+ next();
+});
+
+// Clean-URL routes for extension-less nav links.
+const CLEAN_PAGES = { about: 'history.html', history: 'history.html', care: 'care.html', trade: 'trade.html', sourcing: 'sourcing.html' };
+for (const [route, file] of Object.entries(CLEAN_PAGES)) {
+ app.get('/' + route, (req, res) => res.sendFile(path.join(__dirname, 'public', file)));
+}
+
app.use(express.static(path.join(__dirname, 'public')));
app.get('/api/products', (req, res) => {
@@ -170,7 +185,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 }));
← d757ec5 wire sort select to product grid API
·
back to Vinylwallpaper
·
untrack snapshot/backup files; broaden .gitignore 8404f89 →