← Lesson
BitWithBite
Full-Stack · Quick Reference

Lesson 31 — Deploy to Railway Cheat Sheet

Full-Stack
In one line: Railway hosts your always-on Express server; MongoDB Atlas hosts the database — connect them with env vars and don't forget CORS.

6 Steps

1Create a free Atlas cluster
2Whitelist network access (0.0.0.0/0)
3Push repo to GitHub
4Import repo on railway.app
5Set MONGO_URI + JWT_SECRET

CORS Fix

const cors = require('cors'); app.use(cors({ origin: 'https://your-app.vercel.app' }));
6Point frontend's API URL at the Railway URL