🗒 Cheat Sheet← Lesson
BitWithBite
Full-Stack Worksheet

🚀 Deploy to Railway

Chapter: Deployment & Final Projects · Level ★★★ · Time: 22 min
SCORE___ / 20
NameClassDate
After this worksheet you can
Set up MongoDB AtlasDeploy Express to RailwayConfigure env varsFix CORS between frontend/backend
📚 Quick Recap

🎯 What you'll practice: Hosting a live Express server + MongoDB Atlas database on Railway.

🧠 Section A · Concept Check ● BEGINNER 4 × 1 = 4

1Railway is best suited for:
2MongoDB Atlas network access should allow:
3Requests blocked by CORS fail:
4The env var holding the database connection string is typically:

🧮 Section B · Problem Solving ● INTERMEDIATE 2 + 3×3 = 11

5Railway auto-detects Node.js and runs npm install && npm .
6The Express middleware package used to allow cross-origin requests is .
7Write the cors() config allowing only your Vercel frontend's origin.
8List the 6 deployment steps in order.
9Why must MONGO_URI and JWT_SECRET be set as Railway environment variables instead of hardcoded?

🚀 Section C · Challenge ● CHALLENGE 5

10Your deployed backend logs "MongooseServerSelectionError" on Railway but works locally. Diagnose the most likely cause and the fix.
💭 Reflection — the most useful thing I learned:
A ___/4   B ___/11   C ___/5   Total ___/20 Teacher's Signature Parent's Signature
✂ answer key — fold or cut before handing out

1-B   2-B   3-B   4-B  |  5 = start   6 = cors   7 = app.use(cors({origin:'https://your-app.vercel.app'}));   8 = create Atlas cluster, whitelist network access, push repo to GitHub, import on Railway, set env vars, connect frontend's API URL to the Railway URL   9 = Hardcoding secrets exposes them in source control (visible to anyone with repo access) and makes it impossible to use different values between local/staging/production without editing code  |  10 = Most likely cause: Atlas's network access whitelist doesn't include Railway's IP range (only allows your local IP) — fix by setting network access to 0.0.0.0/0 (or Railway's specific egress IPs) in the Atlas dashboard.

📄 Need offline practice?Print this worksheet or open the one-page cheat sheet.
🗒 Cheat Sheet