Service Type: Web Service
Build Command:
npm run buildStart Command:
npm startSet these in Render dashboard:
NODE_ENV=production
MONGO_URI=your-mongodb-atlas-connection-string
-
Build Process:
- Installs all dependencies
- Builds React frontend to
frontend/build/ - Backend serves both API and static files
-
Production Setup:
- Backend runs on Render's assigned port
- Frontend is served as static files from backend
- No CORS issues (same domain)
- Socket.io works seamlessly
/
├── backend/
│ ├── server.js (serves API + static files)
│ └── ...
├── frontend/
│ └── build/ (React build files)
└── package.json
GET /- Serves React appGET /health- Health checkGET /api/*- Backend API routesPOST /api/*- Backend API routes
- Automatically works on same domain
- No CORS configuration needed
- Real-time features work seamlessly
Render's free tier services spin down after 15 minutes of inactivity. To prevent cold starts:
Option 1: Built-in Keep-Alive (Recommended)
- The app automatically pings
/healthendpoint every 5 minutes when users have the app open - This works well if users are actively using the app
Option 2: External Ping Service (For 24/7 Uptime)
- Use a free service like UptimeRobot or cron-job.org
- Set up a monitor to ping your Render URL every 5 minutes:
URL: https://your-app-name.onrender.com/health Interval: 5 minutes Method: GET
Health Check Endpoint:
GET /health- Returns server status and uptime- Use this for keep-alive pings
✅ Single deployment
✅ No CORS issues
✅ Socket.io works perfectly
✅ Cost effective (one service)
✅ Easy to manage
✅ Built-in keep-alive service