This guide provides step-by-step instructions for deploying the Stock Market Dashboard application on Vercel.
- GitHub account with your code repository
- Vercel account (linked to your GitHub)
-
Push your code to GitHub
- Make sure your updated backend code is pushed to GitHub
-
Deploy Backend to Vercel
- Go to Vercel Dashboard
- Click "Add New" > "Project"
- Import your repository
- Configure project with these settings:
- Project Name:
stock-market-dashboard-backend - Framework Preset: Other
- Root Directory:
backend - Build Command:
npm install - Output Directory: (leave blank)
- Install Command:
npm install
- Project Name:
- Click "Deploy"
-
Add Environment Variables (if needed)
- In Project Settings > Environment Variables, add any required variables
-
Test Backend Deployment
- After deployment completes, test your backend with:
- Visit:
https://[your-backend-url].vercel.app/health - You should see:
{"status":"ok","message":"Server is running"}
-
Push your code to GitHub
- Make sure your updated frontend code is pushed to GitHub
-
Deploy Frontend to Vercel
- Go to Vercel Dashboard
- Click "Add New" > "Project"
- Import your repository
- Configure project with these settings:
- Project Name:
stock-market-dashboard-frontend - Framework Preset: Create React App
- Root Directory:
frontend - Build Command:
npm run build - Output Directory:
build - Install Command:
npm install
- Project Name:
- Click "Deploy"
-
Add Environment Variables
- In Project Settings > Environment Variables, add:
- Key:
REACT_APP_API_URL - Value:
https://[your-backend-url].vercel.app/api - (Make sure to include the
/apipath!)
- Key:
- In Project Settings > Environment Variables, add:
-
Test Frontend Deployment
- After deployment completes, visit your frontend URL
- Ensure the app loads and can fetch data from the backend
If you encounter issues with your deployment, check these common problems:
- Ensure
index.jsis properly exporting the Express app - Check Vercel logs for any errors in Function execution
- Verify CORS settings allow your frontend domain
- Ensure the
REACT_APP_API_URLenvironment variable is set correctly - Check console for any API connection errors
- Verify your API calls include the correct endpoint paths
- The app includes fallback to mock data if API calls fail
- Backend is configured as a serverless function on Vercel
- Frontend is configured as a static site with client-side routing