Deploy BaoBuildBuddy to Railway with a two-service setup.
The railway.json config supports two services (recommended):
| Service | URL |
|---|---|
@bao/server |
https://baoserver-production.up.railway.app |
@bao/client |
https://baoclient-production.up.railway.app |
Important: Set the
@bao/clientservice Root Directory to/(repo root) in Railway Dashboard > Service > Settings > Source. Otherwise the build will fail.
- Railway CLI:
bun install -g @railway/cli - Railway account
- Project ID (from your Railway dashboard URL)
railway login
railway link 75c99e79-2609-45ed-96c9-01806178c76b
railway upNever commit secrets to the repository. Set all sensitive values in the Railway dashboard (Project > Variables) or via CLI.
| Variable | Purpose | Example |
|---|---|---|
DB_PATH |
SQLite database path (use a volume) | /data/bao.db |
CORS_ORIGINS |
Allowed origins | https://your-app.railway.app |
| Variable | Purpose |
|---|---|
OPENAI_API_KEY |
OpenAI cloud provider |
GEMINI_API_KEY |
Google Gemini |
CLAUDE_API_KEY |
Anthropic Claude |
HUGGINGFACE_TOKEN |
HuggingFace Inference API |
Set these on @bao/client so the Nuxt app can reach the API:
| Variable | Value |
|---|---|
NUXT_PUBLIC_API_BASE |
https://baoserver-production.up.railway.app |
NUXT_PUBLIC_WS_BASE |
wss://baoserver-production.up.railway.app |
Do not set BAO_DISABLE_AUTH=true in production. Configure API keys via Settings UI or PUT /api/settings.
Railway's filesystem is ephemeral. To persist the database:
- Go to Railway Dashboard > your service > Volumes.
- Add a volume (e.g. mount path
/data). - Set
DB_PATH=/data/bao.dbin Variables.
The .railway directory (created by railway link) stores your project link. It's in .gitignore and must not be committed.
For CI/CD, use a Project Token:
RAILWAY_TOKEN=your-project-token railway upStore RAILWAY_TOKEN in your CI secrets (e.g. GitHub Actions).
The deployment uses /api/health as the healthcheck path. Ensure this endpoint returns a healthy status for Railway's readiness probes.
| Problem | Fix |
|---|---|
| Build fails | Ensure bun run build succeeds locally. Run bun run typecheck and lint first. |
| DB errors | Verify DB_PATH points to a volume mount. |
| Client returns 426 or wrong port | Set @bao/client Root Directory to / in Railway Dashboard. |
| CORS errors | Add the client domain to CORS_ORIGINS on @bao/server. |