From bd9a28f1b1a636ea381a606706dfdc91f3727f72 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sun, 19 Oct 2025 03:50:00 +0000 Subject: [PATCH] Add DevConnect REST proxy endpoints cgen-7c7ff5d7669445c993a75e5db251f2ae --- server/index.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/server/index.ts b/server/index.ts index de2bc02b..db374590 100644 --- a/server/index.ts +++ b/server/index.ts @@ -19,6 +19,31 @@ export function createServer() { res.json({ message: ping }); }); + // DevConnect REST proxy (GET only) + app.get("/api/devconnect/rest/:table", async (req, res) => { + try { + const base = process.env.DEVCONNECT_URL; + const key = process.env.DEVCONNECT_ANON_KEY; + if (!base || !key) return res.status(500).json({ error: "DevConnect env not set" }); + const table = String(req.params.table || "").replace(/[^a-zA-Z0-9_]/g, ""); + const qs = req.url.includes("?") ? req.url.substring(req.url.indexOf("?")) : ""; + const url = `${base}/rest/v1/${table}${qs}`; + const r = await fetch(url, { + headers: { + apikey: key, + Authorization: `Bearer ${key}`, + Accept: "application/json", + }, + }); + const text = await r.text(); + if (!r.ok) return res.status(r.status).send(text); + res.setHeader("content-type", r.headers.get("content-type") || "application/json"); + return res.status(200).send(text); + } catch (e: any) { + return res.status(500).json({ error: e?.message || String(e) }); + } + }); + app.post("/api/auth/send-verification-email", async (req, res) => { const { email, redirectTo, fullName } = (req.body || {}) as { email?: string;