[object Object]

← back to Embroideredwallpaper

server: add catch-all 404 guard (JSON for /api/*, plain text otherwise); drop dead duplicate /about route (array route already covers it)

fb521b9e5fbf4007fef24f4bcca645e744cb52d4 · 2026-05-25 21:03:48 -0700 · Steve

Files touched

Diff

commit fb521b9e5fbf4007fef24f4bcca645e744cb52d4
Author: Steve <steve@designerwallcoverings.com>
Date:   Mon May 25 21:03:48 2026 -0700

    server: add catch-all 404 guard (JSON for /api/*, plain text otherwise); drop dead duplicate /about route (array route already covers it)
---
 server.js | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/server.js b/server.js
index 87aa904..a0fac13 100644
--- a/server.js
+++ b/server.js
@@ -207,9 +207,6 @@ app.get(['/about', '/history'], (req, res) => {
   res.sendFile(path.join(__dirname, 'public', 'history.html'));
 });
 
-// /about → served by the "short history" page (no dedicated about.html exists)
-app.get('/about', (req, res) => res.sendFile(path.join(__dirname, 'public', 'history.html')));
-
 // sitemap.xml + robots.txt for SEO
 app.get('/robots.txt', (req, res) => {
   res.type('text/plain').send(`User-agent: *
@@ -229,6 +226,12 @@ ${urls.map(u => `  <url><loc>https://embroideredwallpaper.com${u}</loc><changefr
 // Admin catalog CRUD — /admin/catalog (basic-auth) + /api/admin/* REST.
 if (catalog) catalog.mount(app, { siteSlug: SITE_SLUG, rails: SITE_RAILS });
 
+// 404 guard — JSON for /api/*, plain text otherwise. Keep last in route stack.
+app.use((req, res) => {
+  if (req.path.startsWith('/api/')) return res.status(404).json({ error: 'not_found', path: req.path });
+  res.status(404).type('text/plain').send('Not Found');
+});
+
 // Load the catalog. When admin is enabled, prefer dw_unified; else static JSON.
 (async () => {
   let loaded = false;

← 60410aa customer page: drop p.vendor from Ideas rail meta (use patte  ·  back to Embroideredwallpaper  ·  wire api-vendor-redact middleware (close vendors-facet leak) 6a59c3e →