This guide explains how to configure BobInsight to connect to an actual production server instead of localhost.
Deploy both frontend and backend on the same domain (e.g., yourdomain.com).
Configuration:
# .env file - Leave VITE_API_BASE_URL unset or empty
VITE_API_BASE_URL=The frontend will automatically use window.location.origin to connect to the backend.
Example:
- Frontend:
https://yourdomain.com - Backend:
https://yourdomain.com/api
Deploy backend on a separate subdomain (e.g., api.yourdomain.com).
Configuration:
# .env file
VITE_API_BASE_URL=https://api.yourdomain.comExample:
- Frontend:
https://yourdomain.com - Backend:
https://api.yourdomain.com
Important: Configure CORS on backend:
FRONTEND_URL=https://yourdomain.comUse a deployed backend service (Heroku, Railway, Render, etc.).
Configuration:
# .env file
VITE_API_BASE_URL=https://your-app-name.herokuapp.comExample:
- Frontend:
https://bobinsight.vercel.app - Backend:
https://bobinsight-api.herokuapp.com
Important: Configure CORS on backend:
FRONTEND_URL=https://bobinsight.vercel.app- Connect your repository to Vercel
- Set environment variables in Vercel dashboard:
VITE_API_BASE_URL=https://your-backend-url.com - Deploy - Vercel will automatically build and deploy
Build Settings:
- Framework Preset:
Vite - Root Directory:
apps/frontend - Build Command:
npm run build - Output Directory:
dist
-
Create Heroku app:
heroku create your-app-name
-
Set environment variables:
heroku config:set WATSONX_BASE_URL=your_watsonx_url heroku config:set IBM_CLOUD_API_KEY=your_api_key heroku config:set WATSONX_PROJECT_ID=your_project_id heroku config:set FRONTEND_URL=https://your-frontend-url.vercel.app heroku config:set NODE_ENV=production
-
Deploy:
git push heroku main
- Connect repository to Railway
- Set environment variables in Railway dashboard:
WATSONX_BASE_URL=your_watsonx_url IBM_CLOUD_API_KEY=your_api_key WATSONX_PROJECT_ID=your_project_id FRONTEND_URL=https://your-frontend-url.vercel.app NODE_ENV=production PORT=3000 - Deploy - Railway will automatically build and deploy
Using docker-compose.yml:
-
Create
.envfile:# Backend WATSONX_BASE_URL=your_watsonx_url IBM_CLOUD_API_KEY=your_api_key WATSONX_PROJECT_ID=your_project_id FRONTEND_URL=https://your-domain.com # Frontend VITE_API_BASE_URL=https://your-domain.com
-
Deploy:
docker-compose up -d
For production with reverse proxy (nginx):
# Frontend connects to backend via same domain
VITE_API_BASE_URL=Configure nginx to route:
/→ Frontend (port 5173)/api→ Backend (port 3000)
| Variable | Required | Description | Example |
|---|---|---|---|
VITE_API_BASE_URL |
No | Backend API URL. If empty, uses window.location.origin |
https://api.yourdomain.com |
| Variable | Required | Description | Example |
|---|---|---|---|
WATSONX_BASE_URL |
Yes | IBM watsonx.ai base URL | https://us-south.ml.cloud.ibm.com |
IBM_CLOUD_API_KEY |
Yes | IBM Cloud API key | your_api_key_here |
WATSONX_PROJECT_ID |
Yes | watsonx.ai project ID | your_project_id_here |
FRONTEND_URL |
Yes | Frontend URL(s) for CORS | https://yourdomain.com |
PORT |
No | Backend port (default: 3000) | 3000 |
NODE_ENV |
No | Environment (default: development) | production |
curl https://your-backend-url.com/healthExpected response:
{
"status": "ok",
"timestamp": "2026-05-17T11:42:00.000Z"
}Open browser console on your frontend URL and check for:
[API] POST /api/analyze
[API] Response 200 from /api/analyze
If you see CORS errors in browser console:
- Check
FRONTEND_URLis set correctly on backend - Ensure it matches your actual frontend domain
- Include protocol (
https://) in the URL
Cause: Frontend cannot reach backend
Solutions:
- Verify
VITE_API_BASE_URLis set correctly - Check backend is running and accessible
- Test backend health endpoint directly
Cause: Backend rejecting requests from frontend domain
Solutions:
- Set
FRONTEND_URLon backend to match frontend domain - Include protocol in URL:
https://yourdomain.com - For multiple domains, use comma-separated list:
FRONTEND_URL=https://yourdomain.com,https://www.yourdomain.com
Cause: Backend configuration issue
Solutions:
- Verify IBM watsonx.ai credentials are set
- Check backend logs for detailed error messages
- Test backend
/healthendpoint
- Never commit
.envfiles to git - Use environment variables for all secrets
- Enable HTTPS in production
- Configure CORS to allow only your frontend domain
- Set
NODE_ENV=productionon backend - Use secure API keys with minimal required permissions
- Implement rate limiting on backend
- Monitor API usage and costs
# Heroku
heroku logs --tail --app your-app-name
# Railway
railway logs
# Docker
docker logs bobinsight-backend -fCheck browser console for:
- Network errors
- API response errors
- CORS issues
If deployment fails:
-
Revert environment variables to previous working values
-
Redeploy previous version:
# Heroku heroku rollback # Vercel # Use Vercel dashboard to rollback to previous deployment
-
Check logs to identify the issue
For issues or questions:
- Check backend
/healthendpoint - Review browser console for errors
- Check backend logs for detailed error messages
- Verify all environment variables are set correctly
Last Updated: 2026-05-17