[object Object]

← back to 1800swallpaper

fix /api/facets total to count niche-filtered list; add clean-URL routes + .bak 404-guard

9c23b1cf3c870d413f9fb2cb52caa31d2eeaee08 · 2026-05-19 08:18:54 -0700 · SteveStudio2

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

Files touched

Diff

commit 9c23b1cf3c870d413f9fb2cb52caa31d2eeaee08
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date:   Tue May 19 08:18:54 2026 -0700

    fix /api/facets total to count niche-filtered list; add clean-URL routes + .bak 404-guard
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
 server.js | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/server.js b/server.js
index 1692df4..d0aab20 100644
--- a/server.js
+++ b/server.js
@@ -138,8 +138,24 @@ app.use(express.json({ limit: '256kb' }));
 require('./_universal-contact')(app, { siteName: "1800s Wallpaper", zdColor: "#c89060", zdPosition: 'right' });
 require('./_universal-auth')(app, { siteName: "1800swallpaper" });
 
+// 404-guard: never serve snapshot/backup files from the static root.
+app.use((req, res, next) => {
+  if (/\.(bak|pre-[^/]*|orig|tmp|swp)$/i.test(req.path) || /\.bak\./i.test(req.path) || /\.pre-/i.test(req.path)) {
+    return res.status(404).send('Not found');
+  }
+  next();
+});
+
 app.use(express.static(path.join(__dirname, 'public')));
 
+// Clean-URL routes for extension-less nav links.
+const CLEAN_PAGES = ['history', 'care', 'sourcing', 'trade', 'vocabulary'];
+for (const name of CLEAN_PAGES) {
+  app.get('/' + name, (req, res) => res.sendFile(path.join(__dirname, 'public', name + '.html')));
+}
+// /about is referenced throughout the nav/footer; map it to the history page.
+app.get('/about', (req, res) => res.sendFile(path.join(__dirname, 'public', 'history.html')));
+
 app.get('/api/products', (req, res) => {
   const { q, aesthetic, vendor, page = 1, limit = 24, sort = 'newest'} = req.query;
   let list = PRODUCTS_NICHE;
@@ -174,7 +190,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 }));

← ccfe45c hero-4grid: relocate json from data/ to public/ for Express  ·  back to 1800swallpaper  ·  untrack 27 snapshot/backup files; broaden .gitignore for *.b 4ec732a →