This project can run on Replit with the frontend and backend as separate services.
If you don’t see the project on Replit, you need to import it from GitHub first.
- Open this URL in your browser (your GitHub repo):
https://replit.com/github.com/Mats914/Fullstack-React-Node-MongoPostgreSQL- - Press Enter — Replit will open and start importing automatically.
- Log in to Replit if prompted.
- When import finishes, you’ll see the project (files, editor, etc.).
- Go to replit.com/import.
- Select GitHub as the import source.
- Connect your GitHub account if needed.
- Search for the repo
Fullstack-React-Node-MongoPostgreSQL-(or yours) and select it. - Click Import and complete the steps.
After importing, the project appears as a Replit App. You can open files, run it, and add Secrets (MONGODB_URI, JWT_SECRET) as described below.
- Frontend (Vite): port 5000 → Replit Preview (default port 80)
- Backend (Express): port 3001
The project includes .replit and scripts/start-replit.sh. When you press Run:
npm installruns for backend and frontend.- Backend starts on port 3001.
- Frontend (Vite) starts on port 5000 with
host: true(for Replit Preview).
Requirements:
- Secrets (Replit tools → Secrets): add
MONGODB_URIandJWT_SECRET. - Frontend uses
VITE_PROXY_TARGET=http://localhost:3001andVITE_PORT=5000from.replit→[run.env].
Preview: In Replit, open Preview and choose port 80 or 5000 to view the app.
If the single Run script does not work, use Workflows to run two processes in parallel:
- Open Workflows (or ⌘K → Workflows) → + New Workflow.
- Create a Backend workflow:
- Execute Shell Command:
cd backend && npm install && npm run dev - Execution mode: Sequential (or default).
- Execute Shell Command:
- Create a Frontend workflow:
- Execute Shell Command:
cd frontend && npm install && npm run dev - Same mode.
- Execute Shell Command:
- Create a Fullstack workflow:
- Run Workflow → Backend
- Run Workflow → Frontend
- Execution mode: Parallel.
- Assign Fullstack as the workflow for the Run button (dropdown next to Run).
- In Secrets, add:
PORT=3001,MONGODB_URI,JWT_SECRET,VITE_PORT=5000,VITE_PROXY_TARGET=http://localhost:3001.
Run Fullstack and confirm the Console shows output from both backend and frontend.
- Run:
cd backend && npm install && npm run dev(ornpm start) - PORT: Set
PORT=3001in Replit Secrets / Environment. - Required env vars:
MONGODB_URI— MongoDB Atlas connection string (or another MongoDB URI).JWT_SECRET— A long, random string (e.g. 32+ chars).
Without these, the server still starts, but register/login will return:
Database unavailable. Set MONGODB_URI and ensure MongoDB is running.Server configuration error. Set JWT_SECRET in environment variables.
- Run:
cd frontend && npm install && npm run dev - Port: Set
VITE_PORT=5000so the app is served on 5000. - API proxy: Set
VITE_PROXY_TARGET=http://localhost:3001so/apiis proxied to the backend.
Example env for the frontend run:
VITE_PORT=5000
VITE_PROXY_TARGET=http://localhost:3001Use two Replit run targets (or Replit’s “Run” config):
-
Backend:
cd backend && npm run dev- Env:
PORT=3001,MONGODB_URI,JWT_SECRET.
- Env:
-
Frontend:
cd frontend && npm run dev- Env:
VITE_PORT=5000,VITE_PROXY_TARGET=http://localhost:3001.
- Env:
Both must be running. The frontend proxies /api/* to the backend.
Usually means:
-
Backend not reachable
- Backend not running, or wrong port.
- Fix: Run backend on 3001, set
VITE_PROXY_TARGET=http://localhost:3001for frontend.
-
Database not configured
MONGODB_URImissing or MongoDB not running.- Fix: Set
MONGODB_URIand ensure MongoDB (e.g. Atlas) is reachable.
-
JWT not configured
JWT_SECRETmissing.- Fix: Set
JWT_SECRETin the backend environment.
After fixing, you should see the specific 503 messages above instead of a generic “Server error during registration.”
- Backend running on port 3001
- Frontend running on port 5000
-
MONGODB_URIset (Secrets) -
JWT_SECRETset (Secrets) -
VITE_PROXY_TARGET=http://localhost:3001andVITE_PORT=5000(in.replitor Secrets when using Workflows)
If Backend runs but Frontend (Vite) does not appear:
host: true— Added invite.config.tsso Vite listens on0.0.0.0(required for Replit Preview).- Running both — Using
&in a single line sometimes fails. Use either:scripts/start-replit.sh(current Run setup), or- Workflows with two processes (Backend + Frontend) in Parallel as above.
- Port 5000 — Ensure no other process uses it. The Run script starts backend on 3001 first, then frontend on 5000.
- Preview — In Replit, open Preview and select port 80 or 5000 for the app.