#!/bin/sh # FinAI launcher — runs FastAPI (backend) on 127.0.0.1:8000 and # the Next.js standalone server on $PORT (HF Spaces default 7860). set -e # Propagate Spaces-provided PORT (fallback 7860) : "${PORT:=7860}" # Start FastAPI in background cd /home/user/app/apps/api python -m uvicorn mbf.app:app --host 127.0.0.1 --port 8000 --log-level info & API_PID=$! # Give uvicorn a second to bind before Next.js starts proxying sleep 2 # Start Next.js standalone server in foreground (PID 1 receives signals) cd /home/user/app/apps/web export HOSTNAME=0.0.0.0 export NEXT_TELEMETRY_DISABLED=1 # NEXT_PUBLIC_API_URL was baked at build-time; runtime rewrites still work exec node server.js