This guide will walk you through deploying your Netflix Clone application with the backend on Render and frontend on Netlify/Vercel.
- Git installed
- Node.js 18+ installed
- MongoDB Atlas account (already configured)
- GitHub account
- Render account
- Netlify or Vercel account
- Push your code to GitHub:
git add . git commit -m "Prepare for deployment" git push origin main
-
Go to Render Dashboard
-
Create a New Web Service:
- Click "New" → "Web Service"
- Connect your GitHub repository
- Select your
netflix-clonerepository
-
Configure the Service:
- Name:
netflix-clone-backend - Environment:
Node - Region: Choose closest to your users
- Branch:
main - Build Command:
npm install - Start Command:
npm start
- Name:
-
Set Environment Variables:
NODE_ENV=production PORT=10000 MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/database?retryWrites=true&w=majority&appName=YourAppName JWT_SECRET=netflix-clone-super-secret-jwt-key-2024-production-change-this JWT_EXPIRE=7d CORS_ORIGIN=https://your-frontend-domain.netlify.app -
Deploy:
- Click "Create Web Service"
- Wait for deployment to complete
- Note your backend URL:
https://your-app-name.onrender.com
After getting your frontend URL, update the CORS_ORIGIN environment variable in Render with your actual frontend domain.
-
Go to Netlify
-
Deploy from Git:
- Click "New site from Git"
- Choose GitHub and select your repository
- Branch:
main - Publish directory:
.(root) - Build command: Leave empty (static files)
-
Update Configuration:
- After deployment, note your site URL
- Update
js/config.jswith your backend URL:API_BASE_URL: window.location.hostname === 'localhost' ? 'http://localhost:5000/api' : 'https://your-backend-domain.onrender.com/api'
-
Update netlify.toml:
- Replace
https://your-backend-domain.onrender.comwith your actual Render URL
- Replace
-
Go to Vercel
-
Import Project:
- Click "New Project"
- Import from GitHub
- Select your repository
-
Configure:
- Framework Preset: Other
- Root Directory:
./(if deploying from root) - Build Command: Leave empty
- Output Directory: Leave empty
-
Update Configuration:
- Update
vercel.jsonwith your actual backend URL - Update
js/config.jsas mentioned above
- Update
Update your Render environment variables:
CORS_ORIGIN=https://your-actual-frontend-domain.netlify.app
In js/config.js, replace:
'https://your-backend-domain.onrender.com/api'With your actual Render backend URL.
-
Backend Health Check:
- Visit:
https://your-backend-domain.onrender.com/health - Should return:
{"status":"OK","timestamp":"...","environment":"production"}
- Visit:
-
Frontend Test:
- Visit your frontend URL
- Test user registration/login
- Test movie browsing and search
- Test watchlist functionality
- Changed JWT_SECRET to a strong, unique value
- Updated CORS_ORIGIN with actual frontend domain
- MongoDB connection string is secure
- Environment variables are properly set
- HTTPS is enabled (automatic on Render/Netlify/Vercel)
-
CORS Errors:
- Ensure CORS_ORIGIN matches your frontend domain exactly
- Check for trailing slashes or protocol mismatches
-
API Connection Issues:
- Verify backend URL in
js/config.js - Check Render logs for backend errors
- Ensure MongoDB connection is working
- Verify backend URL in
-
Authentication Issues:
- Verify JWT_SECRET is set correctly
- Check browser console for token-related errors
-
Render Cold Starts:
- Free tier services may sleep after inactivity
- First request might be slow (30+ seconds)
- Render: Dashboard → Your Service → Logs
- Netlify: Site Dashboard → Functions → View logs
- Vercel: Project Dashboard → Functions → View logs
-
Render (Backend):
- Go to Settings → Custom Domains
- Add your domain (e.g.,
api.yoursite.com)
-
Netlify/Vercel (Frontend):
- Go to Domain Settings
- Add your custom domain
- Update DNS records as instructed
Both Render and Netlify/Vercel support automatic deployments:
- Auto-deploy: Enabled by default
- Branch: Connected to
mainbranch - Trigger: Every push to main branch
- CPU and Memory usage
- Response times
- Error rates
- Logs
- Netlify/Vercel Analytics
- Browser console errors
- Network requests
-
Backend (Render):
- Enable compression middleware
- Implement caching strategies
- Optimize database queries
-
Frontend (Netlify/Vercel):
- Enable CDN (automatic)
- Optimize images
- Minify CSS/JS (if needed)
- Render: Render Docs
- Netlify: Netlify Docs
- Vercel: Vercel Docs
Your Netflix Clone is now live!
- Backend:
https://your-backend-domain.onrender.com - Frontend:
https://your-frontend-domain.netlify.app
Remember to update the placeholder URLs with your actual deployment URLs and test all functionality after deployment.