This is a full-stack web application using Vite for the frontend and Node.js with Express for the backend.
/frontend # Frontend (React + Vite)
/backend # Backend (Node.js + Express)
- Node.js (>= 20.x recommended)
- npm or yarn
Clone the repository and install dependencies for both frontend and backend.
git clone https://github.com/mridulChhipa/dataFetcher.git
cd dataFetcher
cd backend
npm install
cd frontend
npm install
Create a .env
file in the backend
directory with the following variables:
SUPABASE_URL=...
SUPABASE_ANON_KEY=...
PORT = 3000
CLIENT_URL=http://localhost:5173
Create a .env
file in the frontend
directory with the following variables:
VITE_BACKEND_URL='http://localhost:3000'
cd backend
npm start
The backend runs on http://localhost:3000
(default, can be changed in .env
).
cd frontend
npm run dev
The frontend runs on http://localhost:5173
(default, Vite's default dev server).
cd frontend
npm run build
This generates a production build in the frontend/dist
folder.
Copy the built frontend into the backend's public
folder:
cp -r frontend/dist backend/public
Then modify the backend index.js
to serve static files:
app.use(express.static("public"));
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "public", "index.html"));
});
Now restart the backend, and it will serve both frontend and backend.
For deployment, you can use platforms like:
- Frontend: Vercel (Recommended), Netlify
- Backend: Vercel (Recommended), Heroku, Railway, Render