← back to Raffiawallcoverings
add 404 catch-all guard (JSON for /api/*, text otherwise) — .bak/.pre-* already untracked + ignored
82ccdbce3239e5ec921318da1e2e8ccf1685e3aa · 2026-05-25 21:25:45 -0700 · Steve Abrams
Files touched
Diff
commit 82ccdbce3239e5ec921318da1e2e8ccf1685e3aa
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Mon May 25 21:25:45 2026 -0700
add 404 catch-all guard (JSON for /api/*, text otherwise) — .bak/.pre-* already untracked + ignored
---
server.js | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/server.js b/server.js
index f55c879..aec929a 100644
--- a/server.js
+++ b/server.js
@@ -219,6 +219,13 @@ ${urls.map(u => ` <url><loc>https://raffiawallcoverings.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 catch-all — JSON for /api/*, plain text otherwise. Mounted after every
+// route + static so legitimate paths are unaffected.
+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;
← 2aee93a /api/facets total counts FILTERED list (respects q + aesthet
·
back to Raffiawallcoverings
·
add clean-URL routes: /history /vocabulary /sourcing /care / 4dc8db0 →