Status: Accepted
Date: 2025-01-01
During development, multiple issues arose from running frontend servers on different machines:
- Port Conflicts: Multiple Vite servers fighting for port 5173
- State Confusion: Which server has the latest code?
- WebSocket Issues: Connections to wrong server caused silent failures
- CORS Problems: Cross-origin requests between different origins
- Cache Inconsistency: Different HMR states on different servers
Developers would accidentally start frontend servers locally while the VM was also running, causing hours of debugging "phantom" issues.
Only VM1 (:5173) may run the frontend server.
This is an absolute mandate with zero exceptions:
| Machine | Frontend Server | Status |
|---|---|---|
| Main () | FORBIDDEN | Never start Vite here |
| VM1 () | REQUIRED | Only frontend server |
| All other VMs | FORBIDDEN | No frontend capability |
- Edit locally in
autobot-frontend/ - Sync to VM1 using
./sync-frontend.shor sync scripts - VM1 serves the frontend (dev or production mode)
- Access via
http://<frontend-ip>:5173
-
Local Development with Proxy
- Pros: Familiar workflow, fast HMR
- Cons: Port conflicts, state confusion, CORS issues
-
Multiple Frontend Instances with Load Balancer
- Pros: Redundancy, scaling
- Cons: Overkill, state sync complexity, unnecessary for single user
-
Single Authoritative Server (Chosen)
- Pros: No conflicts, clear source of truth, simple debugging
- Cons: Requires sync step, slightly slower iteration
- No Port Conflicts: Single server, single port
- Clear Source of Truth: Always know which code is running
- Simplified Debugging: Only one place to check logs
- Consistent State: All users see same frontend
- WebSocket Reliability: Single endpoint for real-time features
- Sync Step Required: Must sync changes before seeing them
- Slight Latency: Network round-trip to VM
- VM Dependency: Frontend unavailable if VM1 is down
- HMR still works on VM1, just triggers after sync
- Can use watch mode with auto-sync for smoother workflow
sync-frontend.sh- Quick sync script for frontend changesscripts/utilities/sync-to-vm.sh- General purpose VM sync utility- Systemd services on VM1 manage frontend startup (replaces deprecated
run_autobot.sh)
NEVER run these on the main machine ():
# ALL FORBIDDEN - Will cause conflicts
npm run dev
yarn dev
vite
vite dev
vite preview
pnpm dev# 1. Edit code locally
vim autobot-frontend/src/components/MyComponent.vue
# 2. Sync to VM1
./sync-frontend.sh
# OR
./scripts/utilities/sync-to-vm.sh frontend autobot-frontend/ /home/autobot/autobot-frontend/
# 3. Access in browser
firefox http://<frontend-ip>:5173The systemd service configuration enforces this by:
- Never starting Vite on main machine
- SSH to VM1 to start/restart frontend
- Health checking VM1's frontend server
#!/bin/bash
# .git/hooks/pre-commit
# Warn if Vite process running locally
if pgrep -f "vite" > /dev/null; then
echo "WARNING: Vite is running locally. This violates ADR-005."
echo "Only VM1 (<frontend-ip>) should run the frontend."
exit 1
fiSymptom: Changes not appearing in browser Solution: Run sync script, then hard refresh (Ctrl+Shift+R)
Symptom: WebSocket connection failed Solution: Ensure connecting to :5173, not localhost
Symptom: Port 5173 already in use on main machine
Solution: Kill local process: pkill -f vite
- ADR-001 - VM1 is dedicated frontend server
Author: mrveiss Copyright: © 2025 mrveiss