Full-stack social app with:
- Backend: Node.js + Express + MongoDB + Socket.IO
- Frontend: React + Vite
- Node.js 18+
- MongoDB connection string (Atlas or local)
- Cloudinary account (for image uploads)
- Google OAuth credentials (optional, for Google login)
npm install
npm install --prefix frontendCreate backend/.env:
PORT=5000
CLIENT_URL=http://localhost:5173
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_random_secret
ADMIN_EMAIL=admin@example.com
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secretCreate frontend/.env:
VITE_API_URL=http://localhost:5000/api/v1Terminal 1:
node backend/index.jsTerminal 2:
npm run dev --prefix frontendA simple setup:
- Deploy backend on Render/Railway
- Deploy frontend on Vercel/Netlify
- Use MongoDB Atlas for database
- Push repo to GitHub.
- Create a new Web Service (Render/Railway) from repo.
- Set start command:
node backend/index.js
- Add all
backend/.envvariables in the platform dashboard. - Set
CLIENT_URLto your deployed frontend URL.- You can provide multiple allowed origins as comma-separated values (example:
https://app.vercel.app,https://www.app.com).
- You can provide multiple allowed origins as comma-separated values (example:
- After deployment, copy backend URL, e.g.
https://your-api.onrender.com.
- Import repo to Vercel/Netlify.
- Set frontend build command:
npm run build --prefix frontend
- Set publish directory:
frontend/dist - Add env var:
VITE_API_URL=https://your-api.onrender.com/api/v1
- Redeploy frontend.
In Google Cloud Console, set:
- Authorized JavaScript origins: your frontend URL
- Authorized redirect URI:
https://your-api.onrender.com/api/v1/auth/google/callback
- Build frontend:
npm run build - Start backend:
npm start - Lint frontend:
npm run lint --prefix frontend
If you want, next I can also generate a one-click deployment plan specifically for either Render + Vercel or Railway + Netlify.