Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(server): mount eidoverse proxy before body parsers (#12068)
Adam Eivy6ceca92b7a5f
diff --git a/server/index.js b/server/index.jsindex ba412523ab..959d43b920 100644--- a/server/index.js+++ b/server/index.js@@ -292,6 +292,14 @@ app.use(authGate);// authority: a session, or a local connection on a password-free install.app.use(hostControlRouteGate);+// Eidoverse same-origin reverse-proxy (`/eidoverse-host` + root allowlist while+// the host is active). Must sit above express.json() / express.urlencoded() so+// mutating POST/PUT request body streams are not consumed before proxyHttpToEidoverse+// pipes them upstream (#12068), above mountAssetRoutes so the `/eidoverse-host`+// SERVER_OWNED terminator cannot 404 proxied paths, and above the SPA fallback+// so `/version` / `/ws` are not answered with PortOS index.html.+mountEidoverseOnServer(app);+// Body limit is set slightly above the 50MB combined base64 cap enforced by sendMessageSchema// so the Zod validation (not the body parser) is the binding constraint for attachment payloads.// Every per-file upload cap is derived from this value — see lib/uploadLimits.js.@@ -490,11 +498,6 @@ app.use('/api/harnesses', harnessRoutes);app.use('/api/peer-sync', peerSyncRoutes);app.use('/api/ask', askRoutes);-// Eidoverse same-origin reverse-proxy (`/eidoverse-host` + root allowlist while-// the host is active). Must sit above mountAssetRoutes so the `/eidoverse-host`-// SERVER_OWNED terminator cannot 404 proxied paths, and above the SPA fallback-// so `/version` / `/ws` are not answered with PortOS index.html.-mountEidoverseOnServer(app);// Asset static mounts, then a terminating 404 for every server-owned prefix so// an extensionless `/data/…` or a mistyped `/api/…` can no longer fall throughdiff --git a/server/services/eidoverseProxy.test.js b/server/services/eidoverseProxy.test.jsindex 2373237e7c..538a067031 100644--- a/server/services/eidoverseProxy.test.js+++ b/server/services/eidoverseProxy.test.js@@ -173,4 +173,49 @@ describe('main-server eidoverse reverse-proxy', () => {await once(client, 'close');webSocketClients.pop();});++ it('forwards a JSON POST body when mounted in the production order', async () => {+ let receivedBody = null;+ let receivedHeaders = null;+ const upstreamPort = await listen(createServer((req, res) => {+ receivedHeaders = req.headers;+ let body = '';+ req.setEncoding('utf8');+ req.on('data', (chunk) => { body += chunk; });+ req.on('end', () => {+ receivedBody = body;+ res.writeHead(200, { 'content-type': 'application/json' });+ res.end(JSON.stringify({ ok: true, echo: body ? JSON.parse(body) : null }));+ });+ }));++ // Mirror production order from server/index.js:+ // Eidoverse proxy mounted BEFORE express.json()+ const app = express();+ app.use(createEidoverseExpressMiddleware({+ isActive: () => true,+ targetHost: '127.0.0.1',+ targetPort: upstreamPort,+ getProtocol: () => 'http',+ }));+ app.use(express.json());+ app.use(express.urlencoded({ extended: true }));+ const server = createServer(app);+ const port = await listen(server);++ const payload = { action: 'ping', count: 42 };+ const response = await fetch(`http://127.0.0.1:${port}/eidoverse-host/api/action`, {+ method: 'POST',+ headers: {+ 'content-type': 'application/json',+ },+ body: JSON.stringify(payload),+ });++ expect(response.status).toBe(200);+ const data = await response.json();+ expect(data).toEqual({ ok: true, echo: payload });+ expect(receivedBody).toBe(JSON.stringify(payload));+ expect(Number(receivedHeaders['content-length'])).toBe(Buffer.byteLength(JSON.stringify(payload)));+ });});