This guide covers deploying your Code Editor project to production.
- Frontend: React + Vite + Tailwind CSS (client/)
- Backend: Node.js + Express + MongoDB (server/)
- MongoDB Atlas account (free tier works)
- Accounts on deployment platforms (choose one for each):
- Frontend: Vercel or Netlify
- Backend: Render, Railway, or Vercel
- Go to MongoDB Atlas
- Create a free cluster
- Create a database user
- Whitelist IP:
0.0.0.0/0(all IPs) for production - Get your connection string:
mongodb+srv://username:password@cluster.mongodb.net/code-editor?retryWrites=true&w=majority
-
Push code to GitHub (if not already)
-
Go to Render
-
Create New Web Service
- Connect your GitHub repository
- Root Directory:
server - Environment:
Node - Build Command:
npm install - Start Command:
npm start
-
Add Environment Variables:
MONGODB_URI=<your-mongodb-connection-string> NODE_ENV=production PORT=10000 CORS_ORIGIN=<your-frontend-url>(You'll update CORS_ORIGIN after deploying frontend)
-
Deploy - Copy your backend URL (e.g.,
https://your-app.onrender.com)
- Go to Railway
- New Project → Deploy from GitHub
- Select your repository → Choose
serverdirectory - Add Environment Variables (same as above)
- Generate Domain - Copy your backend URL
-
Install Vercel CLI:
npm install -g vercel
-
From server directory:
cd server vercel -
Add Environment Variables in Vercel dashboard
-
Deploy:
vercel --prod
-
Create
.envfile in client directory:cd ../client cp .env.example .env -
Edit
.env:VITE_API_URL=<your-backend-url>Example:
VITE_API_URL=https://your-app.onrender.com -
Install Vercel CLI (if not already):
npm install -g vercel
-
Deploy:
vercel
Follow prompts, then:
vercel --prod
-
Or use Vercel Dashboard:
- Go to Vercel
- Import your repository
- Root Directory:
client - Framework Preset: Vite
- Add Environment Variable:
VITE_API_URL=<your-backend-url> - Deploy
-
Create
.envfile:cd client cp .env.example .envAdd:
VITE_API_URL=<your-backend-url> -
Install Netlify CLI:
npm install -g netlify-cli
-
Build locally:
npm run build
-
Deploy:
netlify deploy --prod
Choose
distas publish directory -
Or use Netlify Dashboard:
- Go to Netlify
- Import repository
- Build command:
npm run build - Publish directory:
dist - Add environment variable:
VITE_API_URL
After deploying frontend, update your backend CORS_ORIGIN:
- Go to your backend deployment platform
- Update
CORS_ORIGINenvironment variable to your frontend URL Example:https://your-app.vercel.app - Redeploy or restart the backend service
- Visit your frontend URL
- Navigate to the Editor page
- Write some code and click "Run Code"
- Verify output appears correctly
- Ensure
CORS_ORIGINin backend matches your frontend URL exactly (no trailing slash) - Check browser console for exact error
- Verify
VITE_API_URLis set correctly in frontend - Check backend logs for errors
- Ensure MongoDB connection string is correct
- Check if
nodeandpython3are available on your backend platform - Render and Railway support both by default
- Vercel has limitations on code execution - use Render/Railway for backend
- Clear node_modules and reinstall:
rm -rf node_modules && npm install - Check Node version compatibility (use Node 18+)
MONGODB_URI=mongodb+srv://...
NODE_ENV=production
PORT=10000
CORS_ORIGIN=https://your-frontend-url.vercel.app
VITE_API_URL=https://your-backend-url.onrender.com
- MongoDB Atlas: Free (512MB)
- Render: Free tier available (may sleep after inactivity)
- Railway: $5/month credit (free tier)
- Vercel/Netlify: Free for personal projects
Total: $0-5/month
- MongoDB Atlas cluster created
- Backend deployed with environment variables
- Frontend deployed with API_URL configured
- CORS_ORIGIN updated in backend
- Test code execution in production
- Check error handling
- Monitor logs for issues
For best results:
- Frontend: Vercel (fast, free, great DX)
- Backend: Render (free tier, supports code execution)
- Database: MongoDB Atlas (free tier)
This combination is 100% free and production-ready!
# Backend (Render - use dashboard)
# or Railway CLI
cd server
railway login
railway init
railway up
# Frontend (Vercel)
cd client
vercel --prodIf you encounter issues:
- Check platform status pages
- Review deployment logs
- Verify all environment variables
- Test locally first with
npm run dev
Happy deploying! 🚀