Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore(vite): update build configuration

Steven Enamakel6d6a1b43664a
diff --git a/app/vite.config.ts b/app/vite.config.ts
index b3d4b3043b..a9de3e19d5 100644
--- a/app/vite.config.ts
+++ b/app/vite.config.ts
@@ -108,13 +108,35 @@ function guardCefRelListSupportsPlugin(): PluginOption {
// server's own environment and never accepted from the query string, so a
// stray link cannot point a running dev session at an attacker's core.
//
+// `server.host` defaults to `true` above (binds every adapter, not just
+// loopback) to work around the Windows dual-stack `localhost` proxy issue,
+// so this route is reachable from the LAN even though it needs no auth of
+// its own. Restrict it to loopback callers: a LAN peer that can reach this
+// port must not be able to read `OPENHUMAN_CORE_TOKEN` back out of it,
+// especially when combined with the documented `OPENHUMAN_CORE_HOST=0.0.0.0`
+// setup, where that token would then work against the core directly.
+//
// Keys must stay in sync with `app/src/utils/configPersistence.ts`.
+function isLoopbackAddress(address: string | undefined): boolean {
+ if (!address) return false;
+ // Strip an IPv4-mapped-IPv6 prefix (`::ffff:127.0.0.1`) before comparing.
+ const normalized = address.replace(/^::ffff:/, "");
+ return normalized === "127.0.0.1" || normalized === "::1";
+}
+
function devConnectPlugin(): PluginOption {
return {
name: "openhuman:dev-connect",
apply: "serve",
configureServer(server) {
- server.middlewares.use("/__dev-connect", (_req, res) => {
+ server.middlewares.use("/__dev-connect", (req, res) => {
+ if (!isLoopbackAddress(req.socket.remoteAddress)) {
+ res.statusCode = 403;
+ res.setHeader("Content-Type", "text/plain; charset=utf-8");
+ res.end("Forbidden: /__dev-connect is only reachable from loopback.");
+ return;
+ }
+
const token = (process.env.OPENHUMAN_CORE_TOKEN ?? "").trim();
const rpcUrl = (
process.env.VITE_OPENHUMAN_CORE_RPC_URL ?? ""