Skip to content

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

fix(server): serve production UI from Express so npm start avoids hot-reload errors

Adam Eivy884d3ee277eb
diff --git a/.changelog/v1.21.x.md b/.changelog/v1.21.x.md
index 6c39fa7e00..39408ee7ae 100644
--- a/.changelog/v1.21.x.md
+++ b/.changelog/v1.21.x.md
@@ -14,6 +14,7 @@ GSD tab one-click agent spawning and Claude Code launcher.
## Improvements
+- **`npm start` serves production UI** — `npm start` now builds the client and serves the production bundle from the Express server on port 5554, eliminating the need for the Vite dev server and avoiding hot-reload errors during non-development use
- **Add task from app detail page** — the Tasks tab on each app's detail view now includes the CoS TaskAddForm (compact mode) pre-selected to the current app, so you can queue agent tasks without navigating to the CoS page
- **Git status moved to per-app tab** — git status is now a tab within each app's detail view (`/apps/:appId/git`) instead of a standalone cross-app page under Dev Tools, making it contextual to the app you're working on
diff --git a/CLAUDE.md b/CLAUDE.md
index ec41866e2c..6e29b132e3 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -8,14 +8,17 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
# Install all dependencies
npm run install:all
-# Development (both server and client)
+# Start (builds client, serves production UI + API on port 5554)
+npm start
+
+# Development (Vite hot-reload on 5555, API on 5554)
npm run dev
# Run tests
cd server && npm test
cd server && npm run test:watch # Watch mode
-# Production (npm scripts or pm2 directly)
+# PM2 management
pm2 start ecosystem.config.cjs
pm2 stop ecosystem.config.cjs
pm2 logs
diff --git a/package-lock.json b/package-lock.json
index c3f2a7c9b3..58776533fd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "portos",
- "version": "1.21.0",
+ "version": "1.21.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "portos",
- "version": "1.21.0",
+ "version": "1.21.1",
"license": "MIT",
"dependencies": {
"express": "^4.21.2",
diff --git a/package.json b/package.json
index 7fb83ea585..6b7ee6c94e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portos",
- "version": "1.21.0",
+ "version": "1.21.1",
"private": true,
"description": "Local dev machine App OS portal",
"author": "Adam Eivy (@antic|@atomantic)",
@@ -10,7 +10,7 @@
"dev": "node scripts/dev-start.js",
"dev:stop": "node ./node_modules/pm2/bin/pm2 stop ecosystem.config.cjs",
"build": "cd client && npm run build",
- "start": "cd server && npm start",
+ "start": "npm run build && cd server && npm start",
"pm2:start": "node ./node_modules/pm2/bin/pm2 start ecosystem.config.cjs",
"pm2:stop": "node ./node_modules/pm2/bin/pm2 stop ecosystem.config.cjs",
"pm2:restart": "node ./node_modules/pm2/bin/pm2 restart ecosystem.config.cjs",
diff --git a/server/index.js b/server/index.js
index bde8cf9a32..015fbe93ff 100644
--- a/server/index.js
+++ b/server/index.js
@@ -4,6 +4,7 @@ import { createServer } from 'http';
import { Server } from 'socket.io';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
+import { existsSync } from 'fs';
import appleHealthRoutes from './routes/appleHealth.js';
import systemHealthRoutes from './routes/systemHealth.js';
@@ -240,7 +241,18 @@ startBrainScheduler();
// Initialize backup scheduler for daily data backups
startBackupScheduler().catch(err => console.error(`❌ Backup scheduler init failed: ${err.message}`));
-// 404 handler
+// Serve built client UI (production mode — no Vite dev server needed)
+const CLIENT_DIST = join(__dirname, '..', 'client', 'dist');
+if (existsSync(CLIENT_DIST)) {
+ app.use(express.static(CLIENT_DIST));
+ // SPA fallback: serve index.html for non-API routes
+ app.get('*', (req, res) => {
+ res.sendFile(join(CLIENT_DIST, 'index.html'));
+ });
+ console.log(`📦 Serving built UI from client/dist`);
+}
+
+// 404 handler (API routes that didn't match)
app.use((req, res) => {
res.status(404).json({
error: 'Not found',