Deploy the Durusi (دروسي) app on external hosting services like Railway, Render, VPS, Vercel, or DigitalOcean. Use when you need instructions for deploying outside of Replit.
Set these on every hosting platform:
| Variable | Required | Description |
|---|---|---|
MONGODB_URI | Yes | MongoDB connection string (e.g. mongodb+srv://user:[email protected]/durusi) |
ADMIN_PASSWORD | Yes | Password for the admin dashboard at /admin |
PORT | Depends | Server port — some platforms set this automatically |
NODE_ENV | No | Set to production for optimized builds (set automatically by build script) |
# Install dependencies
npm install
# Build the app (compiles frontend + backend into dist/)
npm run build
# Start production server
npm start
npm run build creates a dist/ folder with:
dist/index.cjs — bundled Express serverdist/public/ — compiled React frontend (static files)npm start runs NODE_ENV=production node dist/index.cjsnpm install && npm run buildnpm startMONGODB_URI — your MongoDB Atlas connection stringADMIN_PASSWORD — your chosen admin passwordPORT — no need to set it.up.railway.app URLnpm install && npm run buildnpm startMONGODB_URIADMIN_PASSWORDPORT — no need to add it.onrender.com URLNote: On the free tier, Render spins down after inactivity. First request after sleep may take 30-60 seconds.
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
git clone <your-repo-url> /opt/durusi
cd /opt/durusi
npm install
npm run build
Create a file /opt/durusi/.env:
MONGODB_URI=mongodb+srv://user:[email protected]/durusi
ADMIN_PASSWORD=your_secure_password
PORT=3000
Or export them in your shell / systemd service file.
sudo npm install -g pm2
# Start the app
cd /opt/durusi
PORT=3000 MONGODB_URI="..." ADMIN_PASSWORD="..." pm2 start dist/index.cjs --name durusi
# Auto-restart on reboot
pm2 startup
pm2 save
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache_bypass $http_upgrade;
}
}
Then enable HTTPS with Certbot:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com
Vercel is optimized for serverless. This app uses a long-running Express server, so Vercel is not the ideal choice. Use Railway or Render instead for best results.
If you still want to use Vercel, you would need to:
/api/ directorynpm install && npm run buildnpm startMONGODB_URIADMIN_PASSWORDPORT automatically.ondigitalocean.app URLYour MongoDB Atlas cluster must allow connections from your hosting platform's IP addresses:
0.0.0.0/0 (allow from anywhere). This is safe as long as you use a strong database password.The database name is durusi (included in the connection string). Make sure your MONGODB_URI ends with /durusi, for example:
mongodb+srv://user:[email protected]/durusi
| Problem | Solution |
|---|---|
MONGODB_URI must be set | Environment variable not configured — add it in the platform's settings |
MongoDB connection error | Check Atlas IP whitelist — add 0.0.0.0/0 for cloud platforms |
| App loads but no lessons appear | Ensure the database has seeded data with status: "approved" |
| Arabic text not rendering correctly | Cairo font loads from Google Fonts CDN — ensure outbound HTTPS is allowed |
| Admin login fails | Verify ADMIN_PASSWORD env var is set correctly on the platform |
| Port binding errors | Don't hardcode the port — the app reads from PORT env var, which most platforms set automatically |
If deploying to a fresh database, run the seed script after the first deployment:
# From the project root (with MONGODB_URI exported)
npx tsx server/seed.ts
This inserts sample lessons with status: "approved" so the app has initial content.