Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/ui/web-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ import type {
const log = childLogger("web-server");

const __dirname = dirname(fileURLToPath(import.meta.url));

const publicDir = existsSync(join(__dirname, "public", "index.html"))
? join(__dirname, "public")
: resolve(__dirname, "..", "..", "dist", "ui", "public");

const app = express();
const PORT = parseInt(process.env.PORT || "3847");

Expand Down Expand Up @@ -299,7 +304,7 @@ function createBatchHistoryRecorder({
app.use(express.json({ limit: "50mb" }));

// Serve static frontend
app.use(express.static(join(__dirname, "public")));
app.use(express.static(publicDir));

// File upload config
const uploadDir = join(paths.working, "uploads");
Expand Down Expand Up @@ -2366,7 +2371,7 @@ async function main() {
// SPA fallback: client-side routes (/, /episode, /clip/:id) resolve to the
// built index.html. Registered last so it never shadows /api or static assets.
app.get(/^(?!\/api\/).*/, (_req, res) => {
res.sendFile(join(__dirname, "public", "index.html"));
res.sendFile(join(publicDir, "index.html"));
});

app.listen(PORT, () => {
Expand Down
Loading