[object Object]

← back to Rentv

Fix /api/crm commercial fetch path (CRCP serves /api/brokers/all, not /api/cre/...)

ae9fe73c86f0cb6434652bac130540363e71a071 · 2026-08-12 14:00:20 -0700 · Steve Abrams

Files touched

Diff

commit ae9fe73c86f0cb6434652bac130540363e71a071
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Aug 12 14:00:20 2026 -0700

    Fix /api/crm commercial fetch path (CRCP serves /api/brokers/all, not /api/cre/...)
---
 server.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/server.js b/server.js
index f81a0253..4a8abceb 100644
--- a/server.js
+++ b/server.js
@@ -2332,7 +2332,9 @@ app.get('/api/crm', adminOnly, async (req, res) => {
     let subs = [];
     try { subs = fs.readFileSync(SUBS, 'utf8').split('\n').filter(Boolean).map((l) => { try { return JSON.parse(l); } catch { return null; } }).filter(Boolean); } catch { /* none */ }
     // Owned streams (guarded) + the two small desk sets in parallel.
-    const commercialFetch = fetch(`${CRCP}/api/cre/brokers/all?limit=3000`, { headers: { Authorization: CRCP_AUTH }, signal: AbortSignal.timeout(8000) })
+    // CRCP serves /api/brokers/all directly (the /api/cre prefix belongs to the rentv proxy route,
+    // which backendGet strips before hitting CRCP — so call CRCP's real path here).
+    const commercialFetch = fetch(`${CRCP}/api/brokers/all?limit=3000`, { headers: { Authorization: CRCP_AUTH }, signal: AbortSignal.timeout(10000) })
       .then((r) => r.ok ? r.json() : null).then((j) => (j && (j.brokers || j.rows)) || (Array.isArray(j) ? j : [])).catch(() => []);
     const [subleaseRows, crmPeople, commercialRows] = await Promise.all([fetchSubleaseRows(), fetchCrmContacts(), commercialFetch]);
     const owned = buildAudience(subs, subleaseRows, crmPeople);           // { stats, segments, contacts }

← 3a582b15 Fix CRCP proxy auth double-encoding (CRM Commercial type was  ·  back to Rentv  ·  CRM: add Directory/Lists imported-contact type + LABJ Book-o fe5ea865 →