[object Object]

← back to Rentv 2026

rentv: proxy homesonspec + crcp backends into the admin Desk

3c12ff4c76f94ed2329b39a776560febbef7ce91 · 2026-07-29 08:00:33 -0700 · Steve Abrams

Adds admin-gated read-only GET passthroughs mirroring the usre pattern:
  /api/homes/*  -> homesonspec-web :9975 /api/*   (open loopback; spec-home inventory)
  /api/cre/*    -> commercialrealestate :9911 /api/*  (crcp CRM; auth via CRCP_AUTH_B64 env only)
crcp cred is read from prod env (CRCP_AUTH_B64), never committed. homesonspec + usre
verified live (200, admin-gated 403 for user tier); crcp pending env cred injection.

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

Files touched

Diff

commit 3c12ff4c76f94ed2329b39a776560febbef7ce91
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Jul 29 08:00:33 2026 -0700

    rentv: proxy homesonspec + crcp backends into the admin Desk
    
    Adds admin-gated read-only GET passthroughs mirroring the usre pattern:
      /api/homes/*  -> homesonspec-web :9975 /api/*   (open loopback; spec-home inventory)
      /api/cre/*    -> commercialrealestate :9911 /api/*  (crcp CRM; auth via CRCP_AUTH_B64 env only)
    crcp cred is read from prod env (CRCP_AUTH_B64), never committed. homesonspec + usre
    verified live (200, admin-gated 403 for user tier); crcp pending env cred injection.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 server.js | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/server.js b/server.js
index 65e33db0..993bb01f 100644
--- a/server.js
+++ b/server.js
@@ -369,6 +369,32 @@ app.delete('/api/admin/sublease/:id', adminOnly, (req, res) => {
   return usreWrite('DELETE', '/api/admin/sublease/' + id, req, res);
 });
 
+// ── Also hook the Desk to two more loopback backends (same adminOnly gate): ──
+//   homesonspec-web (new-construction / spec-home inventory) — open on loopback.
+//   commercialrealestate / "crcp" (commercial-RE CRM) — basic-auth-gated; inject the cred.
+// Generic READ-ONLY GET passthrough so every upstream endpoint is reachable without
+// hardcoding each; writes are NOT proxied (upstream apps own their own writes).
+const HOS = process.env.HOS_URL || 'http://127.0.0.1:9975';   // homesonspec-web
+const CRCP = process.env.CRCP_URL || 'http://127.0.0.1:9911'; // commercialrealestate CRM
+// Cred comes ONLY from the prod env (CRCP_AUTH_B64), never committed to source. Empty ⇒ the
+// crcp proxy returns 401/502 until the env var is set on the server (see rentv prod .env).
+const CRCP_AUTH = process.env.CRCP_AUTH_B64 ? 'Basic ' + process.env.CRCP_AUTH_B64 : '';
+async function backendGet(base, auth, prefix, req, res) {
+  try {
+    const sub = req.path.slice(prefix.length) || '/';           // strip the rentv prefix → upstream sub-path
+    const qs = new URLSearchParams(req.query).toString();
+    const url = `${base}/api${sub}${qs ? '?' + qs : ''}`;
+    const r = await fetch(url, { headers: auth ? { Authorization: auth } : {}, signal: AbortSignal.timeout(12000) });
+    const body = await r.text();
+    res.status(r.status).set('Cache-Control', 'public, max-age=120')
+       .type(r.headers.get('content-type') || 'application/json').send(body);
+  } catch (e) { res.status(502).json({ error: 'backend unavailable' }); }
+}
+// rentv /api/homes/* → homesonspec :9975 /api/*   (e.g. /api/homes/search, /api/homes/facets)
+app.get('/api/homes/*', adminOnly, (req, res) => backendGet(HOS, null, '/api/homes', req, res));
+// rentv /api/cre/* → crcp :9911 /api/*   (prefix 'cre' avoids colliding with crcp's own /api/crcp/*)
+app.get('/api/cre/*', adminOnly, (req, res) => backendGet(CRCP, CRCP_AUTH, '/api/cre', req, res));
+
 // ── AUDIENCE / CRM (/audience): unify the two real contact streams RENTV owns —
 //    newsletter subscribers (subscribers.jsonl) + sublease listing brokers
 //    (/api/sublease) — into one prospect list with AUTO-DERIVED segments.

← 689e1cd6 Replace build slideshow with full front+backend walkthrough  ·  back to Rentv 2026  ·  rentv Desk: add New Homes scope (homesonspec spec-home inven 482ee13d →