[object Object]

← back to Wallco Ai

Guard /api/design and /api/design/ (missing id) → redirect home instead of raw Cannot GET 404

703d174d89e166ae682cce6b6054d6d61369559f · 2026-06-01 12:25:44 -0700 · Steve Abrams

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

Files touched

Diff

commit 703d174d89e166ae682cce6b6054d6d61369559f
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon Jun 1 12:25:44 2026 -0700

    Guard /api/design and /api/design/ (missing id) → redirect home instead of raw Cannot GET 404
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 server.js | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/server.js b/server.js
index 4c54280..9954577 100644
--- a/server.js
+++ b/server.js
@@ -464,6 +464,10 @@ app.get('/api/coordinates/ai', async (req, res) => {
 // width_in, height_in, prompt) so a client-side template can render every
 // PDP field without touching the giant server-side template. Used by
 // /design/:id/bento (theme V2). Strips local_path before send.
+// Missing-id guard: a request to /api/design or /api/design/ (no id) would
+// otherwise fall through to Express's raw "Cannot GET /api/design/" 404.
+// Send the visitor home instead.
+app.get(['/api/design', '/api/design/'], (req, res) => res.redirect(302, '/'));
 app.get('/api/design/:id', (req, res) => {
   const id = parseInt(req.params.id, 10);
   if (!Number.isFinite(id) || id < 1) return res.status(400).json({ error: 'bad id' });

← 5a812ec feat(styleguides): open to public with per-IP render cap (5  ·  back to Wallco Ai  ·  feat(designs): add Color (group similar hues, H→L) + Style s e04b3d1 →