[object Object]

← back to Hospitalitywallcoverings

add 404-guard route; remove stale .bak/.pre- files (already gitignored)

4ad4a98ce46f366cd440d82a38f360f9b35c7590 · 2026-05-25 21:11:00 -0700 · Steve Abrams

Files touched

Diff

commit 4ad4a98ce46f366cd440d82a38f360f9b35c7590
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon May 25 21:11:00 2026 -0700

    add 404-guard route; remove stale .bak/.pre- files (already gitignored)
---
 server.js | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/server.js b/server.js
index 950475c..cc5a0b5 100644
--- a/server.js
+++ b/server.js
@@ -233,6 +233,13 @@ ${urls.map(u => `  <url><loc>https://hospitalitywallcoverings.com${u}</loc><chan
 // 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. Registered last so it
+// only fires when no route or static asset matched.
+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;

← aa88490 retag aesthetic from PG: 598 rows updated  ·  back to Hospitalitywallcoverings  ·  add noreferrer to target=_blank Facebook link 2aca15e →