cd backend && npm install && npm run buildImportant: The build script automatically installs frontend dev dependencies with --include=dev flag to ensure vite is available.
cd backend && npm startGOOGLE_API_KEY=your_google_ai_api_key_here
NODE_ENV=production
- Web Service (Node.js)
- NOT Static Site
-
Build Phase:
- Installs backend dependencies
- Runs
npm run buildwhich installs frontend deps and builds React app - Creates
frontend/distfolder with built frontend
-
Runtime:
- Backend serves API on
/ai/*routes - Backend serves React app on all other routes (
/*) - Single URL serves both frontend and API
- Backend serves API on
- Go to Render Dashboard β "New" β "Web Service"
- Connect GitHub repository
- Set Service Type to "Web Service" (not Static Site)
- Use the Build and Start commands above
- Set
GOOGLE_API_KEYenvironment variable - Deploy
- Visit your service URL (e.g.,
https://refactorai-app-xyz.onrender.com) - Frontend loads at root (
/) - API works at
/ai/get-review - Health check available at
/health
For easier deployment, use the included render.yaml file:
- Go to Render β "New" β "Blueprint"
- Connect GitHub repository
- Render auto-detects
render.yaml - Only set
GOOGLE_API_KEYenvironment variable - Deploy automatically
Test the production build locally:
# Build everything
node build.js
# Start server
cd backend && npm start
# Visit http://localhost:3000β Lower Cost - Only one service instead of two β Simpler Setup - No CORS issues, same origin β Easier Deployment - Single service to manage β Better Performance - No cross-origin requests