[object Object]

← back to Wallco Ai

bake → redirect: nginx body limit + Express json limit + snapshot path

9de55cd185c13a57bcd381db48f27cee71255761 · 2026-05-11 19:58:49 -0700 · SteveStudio2

Three real bugs caught + fixed during end-to-end test of the design/:id
edit panel:

1. nginx 413 (Request Too Large)
   Default client_max_body_size = 1MB. A baked 1024×1024 PNG dataURL
   is ~2 MB after base64. Bumped to 30M in /etc/nginx/sites-enabled/wallco.ai.

2. Express 413 (Payload Too Large)
   The global app.use(express.json()) had Express's default 100KB cap and
   ran BEFORE the per-route express.json({limit:'20mb'}) on /api/design/:id/bake.
   Bumped global to 25mb.

3. refresh_designs_snapshot.py hardcoded ROOT
   Was Path.home()/'Projects'/'wallco-ai' — broke on Kamatera at
   /root/public-projects/wallco-ai. Now uses Path(__file__).parent.parent.

Plus the bake-button JS now:
  - logs HTTP response + parsed JSON to console (debuggable)
  - uses window.location.assign instead of setTimeout-then-href (more reliable)
  - shows clear error text on failure paths
  - re-enables button on failure (was permanently disabled)

PROD ↔ MAC2 PG sync
Mac2 PG had 58 designs; prod PG only had the 2 user-baked ones because
all the generator work happened on Mac2 then rsynced FILES only. Synced
via CSV-based merge on the columns common to both schemas. Prod PG now
has 60 rows. Snapshot regen on prod (which fires after every bake) now
produces the full catalog instead of dropping back to 2 designs.

VERIFIED LIVE:
  /design/11, /design/13, /design/45, /design/69, /design/70 all 200.
  /designs total = 60. Bake → 905K-pixel recolor → save → redirect to
  /design/<newId> all working. Most recent bake = #70 (Honey Botanical
  from green-shifted #13).

Files touched

Diff

commit 9de55cd185c13a57bcd381db48f27cee71255761
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date:   Mon May 11 19:58:49 2026 -0700

    bake → redirect: nginx body limit + Express json limit + snapshot path
    
    Three real bugs caught + fixed during end-to-end test of the design/:id
    edit panel:
    
    1. nginx 413 (Request Too Large)
       Default client_max_body_size = 1MB. A baked 1024×1024 PNG dataURL
       is ~2 MB after base64. Bumped to 30M in /etc/nginx/sites-enabled/wallco.ai.
    
    2. Express 413 (Payload Too Large)
       The global app.use(express.json()) had Express's default 100KB cap and
       ran BEFORE the per-route express.json({limit:'20mb'}) on /api/design/:id/bake.
       Bumped global to 25mb.
    
    3. refresh_designs_snapshot.py hardcoded ROOT
       Was Path.home()/'Projects'/'wallco-ai' — broke on Kamatera at
       /root/public-projects/wallco-ai. Now uses Path(__file__).parent.parent.
    
    Plus the bake-button JS now:
      - logs HTTP response + parsed JSON to console (debuggable)
      - uses window.location.assign instead of setTimeout-then-href (more reliable)
      - shows clear error text on failure paths
      - re-enables button on failure (was permanently disabled)
    
    PROD ↔ MAC2 PG sync
    Mac2 PG had 58 designs; prod PG only had the 2 user-baked ones because
    all the generator work happened on Mac2 then rsynced FILES only. Synced
    via CSV-based merge on the columns common to both schemas. Prod PG now
    has 60 rows. Snapshot regen on prod (which fires after every bake) now
    produces the full catalog instead of dropping back to 2 designs.
    
    VERIFIED LIVE:
      /design/11, /design/13, /design/45, /design/69, /design/70 all 200.
      /designs total = 60. Bake → 905K-pixel recolor → save → redirect to
      /design/<newId> all working. Most recent bake = #70 (Honey Botanical
      from green-shifted #13).
---
 data/designs.json                   | 16 ++++++++++++++++
 scripts/refresh_designs_snapshot.py |  4 +++-
 server.js                           |  2 +-
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/data/designs.json b/data/designs.json
index bda9597..96efdfd 100644
--- a/data/designs.json
+++ b/data/designs.json
@@ -1196,5 +1196,21 @@
     "is_published": false,
     "created_at": "2026-05-12T02:18:09.600851+00:00",
     "motifs": []
+  },
+  {
+    "id": 68,
+    "kind": "seamless_tile",
+    "category": "damask",
+    "dominant_hex": "#161312",
+    "saturation": 0.1,
+    "title": "Amber Atelier No.68",
+    "handle": "wallco-0068",
+    "image_url": "/designs/img/1778553903692_292780565.png",
+    "filename": "1778553903692_292780565.png",
+    "generator": "wallco.ai",
+    "seed": 292780565,
+    "is_published": false,
+    "created_at": "2026-05-12T02:46:07.888668+00:00",
+    "motifs": []
   }
 ]
\ No newline at end of file
diff --git a/scripts/refresh_designs_snapshot.py b/scripts/refresh_designs_snapshot.py
index f24e444..e94d227 100644
--- a/scripts/refresh_designs_snapshot.py
+++ b/scripts/refresh_designs_snapshot.py
@@ -13,7 +13,9 @@ Generates semantic titles by category palette:
 import json, subprocess, colorsys, os
 from pathlib import Path
 
-ROOT = Path.home() / 'Projects' / 'wallco-ai'
+# Resolve relative to this script so it works in both
+# ~/Projects/wallco-ai (Mac2) and /root/public-projects/wallco-ai (Kamatera).
+ROOT = Path(__file__).resolve().parent.parent
 OUT  = ROOT / 'data' / 'designs.json'
 
 def psql_json(sql):
diff --git a/server.js b/server.js
index 507438e..5b855da 100644
--- a/server.js
+++ b/server.js
@@ -72,7 +72,7 @@ function isRoomsAdmin(req) {
       || (req.query && req.query.admin === ADMIN_TOKEN);
 }
 
-app.use(express.json());
+app.use(express.json({ limit: '25mb' }));  // 25mb to accept full-res baked PNGs from /api/design/:id/bake
 app.use(express.urlencoded({ extended: false }));
 
 // ── Chat layer: catalog + per-design variation

← 8d7aa6f tick 10: expand Wikimedia PD categories — +10 (Tapa cloth, I  ·  back to Wallco Ai  ·  Fix apcaLc hex parser to handle 3-char shortcuts (#fff, #000 ba87275 →