← back to Silverleafwallpaper
add 404-guard middleware (JSON for /api/*, lightweight HTML elsewhere) + remove untracked .bak/.pre-* clutter from disk
326d06dced7ef81a485fc00ba54c7de225a59c5e · 2026-05-25 21:36:15 -0700 · Steve
Files touched
Diff
commit 326d06dced7ef81a485fc00ba54c7de225a59c5e
Author: Steve <steve@designerwallcoverings.com>
Date: Mon May 25 21:36:15 2026 -0700
add 404-guard middleware (JSON for /api/*, lightweight HTML elsewhere) + remove untracked .bak/.pre-* clutter from disk
---
server.js | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/server.js b/server.js
index 1f5830b..bdfacdc 100644
--- a/server.js
+++ b/server.js
@@ -219,6 +219,15 @@ ${urls.map(u => ` <url><loc>https://silverleafwallpaper.com${u}</loc><changefre
// 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/*, lightweight HTML for everything else. Sits at
+// the bottom of the route table; any request that falls past every handler
+// (e.g. /care.html.bak, /old-page, stray .bak/.pre-* probes) lands here
+// instead of bubbling to Express's default text/html 404.
+app.use((req, res) => {
+ if (req.path.startsWith('/api/')) return res.status(404).json({ error: 'not_found', path: req.path });
+ res.status(404).type('html').send('<!doctype html><meta charset=utf-8><title>404</title><body style="font:14px/1.6 system-ui;padding:48px;color:#666"><h1 style="font-weight:400">404</h1><p>That page does not exist. <a href="/" style="color:#888">Back to home →</a></p></body>');
+});
+
// Load the catalog. When admin is enabled, prefer dw_unified; else static JSON.
(async () => {
let loaded = false;
← 1106b8a hydrate saved sort BEFORE first grid load — first paint matc
·
back to Silverleafwallpaper
·
add noopener noreferrer to target=_blank + window.open (FB l 2f96e5f →