From a248245884508d20fc368c605f61c358f905e787 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Sun, 16 Nov 2025 12:18:54 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20fix:=20serve=20mux=20server=20re?= =?UTF-8?q?nderer=20from=20dist=20root?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _Generated with _ --- src/cli/server.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cli/server.ts b/src/cli/server.ts index 4b29866f0..280c29a39 100644 --- a/src/cli/server.ts +++ b/src/cli/server.ts @@ -8,6 +8,7 @@ import { IpcMain } from "@/node/services/ipcMain"; import { migrateCmuxToMux } from "@/common/constants/paths"; import cors from "cors"; import type { BrowserWindow, IpcMain as ElectronIpcMain } from "electron"; +import { existsSync } from "fs"; import express from "express"; import * as http from "http"; import * as path from "path"; @@ -140,6 +141,14 @@ app.use(express.json({ limit: "50mb" })); const clients: Clients = new Map(); const mockWindow = new MockBrowserWindow(clients); +const STATIC_ROOT = path.resolve(__dirname, ".."); +const STATIC_INDEX = path.join(STATIC_ROOT, "index.html"); + +if (!existsSync(STATIC_INDEX)) { + console.warn( + `[mux-server] Built renderer missing at ${STATIC_INDEX}. Did you run "make build-renderer"?` + ); +} const httpIpcMain = new HttpIpcMainAdapter(app); // Initialize async services and register handlers @@ -176,7 +185,7 @@ const httpIpcMain = new HttpIpcMainAdapter(app); }); // Serve static files from dist directory (built renderer) - app.use(express.static(path.join(__dirname, "."))); + app.use(express.static(STATIC_ROOT)); // Health check endpoint app.get("/health", (req, res) => { @@ -186,7 +195,7 @@ const httpIpcMain = new HttpIpcMainAdapter(app); // Fallback to index.html for SPA routes (use middleware instead of deprecated wildcard) app.use((req, res, next) => { if (!req.path.startsWith("/ipc") && !req.path.startsWith("/ws")) { - res.sendFile(path.join(__dirname, "index.html")); + res.sendFile(path.join(STATIC_ROOT, "index.html")); } else { next(); }