Skip to content

Commit af7d802

Browse files
authored
🤖 fix: serve mux server renderer from dist root (#630)
## Summary - serve mux server static assets from dist root to match vite output - log a helpful warning if the bundle is missing so users run the renderer build ## Testing - make typecheck _Generated with _
1 parent b7aa9a6 commit af7d802

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/cli/server.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { IpcMain } from "@/node/services/ipcMain";
88
import { migrateCmuxToMux } from "@/common/constants/paths";
99
import cors from "cors";
1010
import type { BrowserWindow, IpcMain as ElectronIpcMain } from "electron";
11+
import { existsSync } from "fs";
1112
import express from "express";
1213
import * as http from "http";
1314
import * as path from "path";
@@ -140,6 +141,14 @@ app.use(express.json({ limit: "50mb" }));
140141
const clients: Clients = new Map();
141142

142143
const 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+
}
143152
const 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

Comments
 (0)