@@ -8,6 +8,7 @@ import { IpcMain } from "@/node/services/ipcMain";
88import { migrateCmuxToMux } from "@/common/constants/paths";
99import cors from "cors";
1010import type { BrowserWindow, IpcMain as ElectronIpcMain } from "electron";
11+ import { existsSync } from "fs";
1112import express from "express";
1213import * as http from "http";
1314import * as path from "path";
@@ -140,6 +141,14 @@ app.use(express.json({ limit: "50mb" }));
140141const clients: Clients = new Map();
141142
142143const mockWindow = new MockBrowserWindow(clients);
144+ const STATIC_ROOT = path.resolve(__dirname, "..");
145+ const STATIC_INDEX = path.join(STATIC_ROOT, "index.html");
146+
147+ if (!existsSync(STATIC_INDEX)) {
148+ console.warn(
149+ `[mux-server] Built renderer missing at ${STATIC_INDEX}. Did you run \"make build-renderer\"?`
150+ );
151+ }
143152const httpIpcMain = new HttpIpcMainAdapter(app);
144153
145154// Initialize async services and register handlers
@@ -176,7 +185,7 @@ const httpIpcMain = new HttpIpcMainAdapter(app);
176185 });
177186
178187 // Serve static files from dist directory (built renderer)
179- app.use(express.static(path.join(__dirname, ".") ));
188+ app.use(express.static(STATIC_ROOT ));
180189
181190 // Health check endpoint
182191 app.get("/health", (req, res) => {
@@ -186,7 +195,7 @@ const httpIpcMain = new HttpIpcMainAdapter(app);
186195 // Fallback to index.html for SPA routes (use middleware instead of deprecated wildcard)
187196 app.use((req, res, next) => {
188197 if (!req.path.startsWith("/ipc") && !req.path.startsWith("/ws")) {
189- res.sendFile(path.join(__dirname , "index.html"));
198+ res.sendFile(path.join(STATIC_ROOT , "index.html"));
190199 } else {
191200 next();
192201 }
0 commit comments