Problem:
- Requests were going to
https://vercel-frontend.com/api/auth/logininstead of backend REACT_APP_API_BASE_URLenvironment variable was never set
Solution Applied:
- Fixed
Login.jsto usebuildApiUrl()helper function - All API calls now properly route through
buildApiUrl() - This function will use
REACT_APP_API_BASE_URLwhen available
Problem:
- Backend only allowed
http://localhost:3000 - Vercel frontend requests were blocked by CORS policy
Solution Applied:
- Updated
server.jsCORS configuration to accept:- Localhost (for development)
- Vercel URLs (
*.vercel.app) - Render URLs (
*.render.com) - Netlify URLs (
*.netlify.app)
- Added
credentials: truefor cookie/session support
Problem:
Login.jswas using hardcoded/api/authpath- Couldn't handle production URLs
Solution Applied:
- Imported
buildApiUrlfromutils/api - Updated all API calls:
/api/auth/google-login/api/auth/signup/api/auth/login
- All now use
buildApiUrl()for proper domain routing
backend/server.js- CORS configuration updatedfrontend/src/pages/Login.js- Now uses buildApiUrl helper
✅ Code Changes: COMPLETE
❌ Environment Variables: NOT DONE YET (Your Action Required)
- Get your Render backend URL
- Add
REACT_APP_API_BASE_URLto Vercel environment variables - Add
REACT_APP_RAZORPAY_KEY_IDto Vercel environment variables - Redeploy Vercel after adding env vars
- Verify Render backend is restarted
- Test Login, Payment, Google Sign-in
✅ Email Login - Should work without CORS errors
✅ Google Login - Should work without CORS errors
✅ Razorpay Payment - Should open payment modal and process payments
✅ Profile Page - Should fetch and display user data
✅ All API Routes - Will properly resolve to backend domain
📖 See detailed instructions in: DEPLOYMENT_FIX_GUIDE.md
This guide has:
- Step-by-step Vercel setup
- Step-by-step Render setup
- Testing checklist
- Troubleshooting guide
- Quick reference URLs