After deploying, you need to configure the environment variables to point to your deployed server URLs.
Update the root .env file with your deployed frontend URL:
# =============================================================================
# FRONTEND URL CONFIGURATION (for password reset links)
# =============================================================================
FRONTEND_URL=https://your-frontend-domain.comUpdate the client/.env file with your deployed backend URL:
# Backend API URL - Change this to your deployed server URL
VITE_API_URL=https://your-backend-domain.com- Update the
client/.envfile with your production backend URL - Build the React frontend:
cd client
npm run buildThe build output will be in client/dist/ and can be served by any static web server (Nginx, Apache, etc.).
- Make sure the
.envfile in the root directory has the correctFRONTEND_URL - The backend will serve the frontend from the
/distfolder if available, or you can serve them separately
If your backend is at https://api.zerohealth.com and frontend at https://zerohealth.com:
Backend .env:
FRONTEND_URL=https://zerohealth.comFrontend client/.env:
VITE_API_URL=https://api.zerohealth.comIf you're serving both from the same domain with the API at /api:
Frontend client/.env:
VITE_API_URL=https://zerohealth.comThen configure your reverse proxy (Nginx) to:
- Serve frontend files from
/ - Proxy
/apirequests to the backend server
If using Docker, update the environment variables in your docker-compose.yml or pass them when running:
docker-compose up -dMake sure to update the environment variables in the compose file for production deployments.
- Make sure you've updated
client/.envwith the correctVITE_API_URL - Rebuild the frontend after changing environment variables:
cd client && npm run build - Clear your browser cache to ensure it loads the new built files
- Check that the backend
.envfile has the correctFRONTEND_URL - Restart the backend server after updating the
.envfile
If you encounter CORS errors when frontend and backend are on different domains, ensure your backend includes the appropriate CORS headers for your frontend domain.