Getting "Network Error" when trying to create mint voucher or call backend API.
In Vercel/Render Dashboard:
Verify VITE_API_URL is set correctly:
- Should be:
https://your-backend-url.vercel.app/api(or.onrender.com/api) - Must end with
/api - Must be the full URL (not relative)
Check in browser console: Open DevTools (F12) → Console tab, look for:
🔧 API Configuration: { VITE_API_URL: "...", API_BASE_URL: "..." }
Test backend directly:
# Replace with your actual backend URL
curl https://your-backend-url.vercel.app/healthShould return:
{"status":"healthy","timestamp":"...","version":"1.0.0"}Backend must allow your frontend URL:
In backend environment variables:
FRONTEND_URL=https://your-frontend-url.vercel.app
Or for Render:
FRONTEND_URL=https://your-frontend-url.onrender.com
Symptom: Console shows VITE_API_URL: undefined
Fix:
- Go to Vercel/Render → Project Settings → Environment Variables
- Add:
VITE_API_URL=https://your-backend-url/api - Redeploy frontend
Symptom: API calls fail with CORS or 404
Fix:
- ✅ Correct:
https://backend.vercel.app/api - ❌ Wrong:
https://backend.vercel.app(missing/api) - ❌ Wrong:
/api(relative URL won't work)
Symptom: Network error, can't reach backend
Fix:
- Deploy backend first
- Copy backend URL
- Update frontend
VITE_API_URL - Redeploy frontend
Symptom: CORS error in console
Fix:
- Check backend
FRONTEND_URLenvironment variable - Must match your frontend URL exactly
- No trailing slash
- Redeploy backend after updating
-
Get Backend URL
- Go to backend project in Vercel
- Copy the deployment URL (e.g.,
https://hashmon-backend.vercel.app)
-
Update Frontend Environment Variable
- Go to frontend project → Settings → Environment Variables
- Set:
VITE_API_URL=https://hashmon-backend.vercel.app/api - Important: Add
/apiat the end
-
Update Backend CORS
- Go to backend project → Settings → Environment Variables
- Set:
FRONTEND_URL=https://hashmon-frontend.vercel.app - No trailing slash
-
Redeploy Both
- Frontend: Redeploy after adding
VITE_API_URL - Backend: Redeploy after adding
FRONTEND_URL
- Frontend: Redeploy after adding
-
Get Backend URL
- Go to backend service in Render
- Copy the service URL (e.g.,
https://hashmon-backend.onrender.com)
-
Update Frontend Environment Variable
- Go to frontend static site → Environment
- Set:
VITE_API_URL=https://hashmon-backend.onrender.com/api
-
Update Backend CORS
- Go to backend service → Environment
- Set:
FRONTEND_URL=https://hashmon-frontend.onrender.com
-
Redeploy Both
- Both will auto-redeploy on save
curl https://your-backend-url/health
curl https://your-backend-url/apiOpen browser console (F12) and run:
// Check API URL
console.log('API URL:', import.meta.env.VITE_API_URL)
// Test API call
fetch(import.meta.env.VITE_API_URL + '/health')
.then(r => r.json())
.then(console.log)
.catch(console.error)-
Check Browser Console
- Look for API configuration log
- Check for CORS errors
- Check network tab for failed requests
-
Check Network Tab
- Open DevTools → Network tab
- Try creating mint voucher
- Look for failed request
- Check request URL and response
-
Check Backend Logs
- Vercel: Functions → Logs
- Render: Service → Logs tab
- Look for incoming requests
-
Verify URLs Match
- Frontend
VITE_API_URLshould match backend URL +/api - Backend
FRONTEND_URLshould match frontend URL exactly
- Frontend
- Check browser console for specific error messages
- Test backend directly with curl or Postman
- Verify environment variables are set correctly
- Check deployment logs for build/runtime errors
- Try hard refresh (Ctrl+Shift+R or Cmd+Shift+R)
Backend Project:
- URL:
https://hashmon-backend.vercel.app - Env Var:
FRONTEND_URL=https://hashmon-frontend.vercel.app
Frontend Project:
- URL:
https://hashmon-frontend.vercel.app - Env Var:
VITE_API_URL=https://hashmon-backend.vercel.app/api
Backend Service:
- URL:
https://hashmon-backend.onrender.com - Env Var:
FRONTEND_URL=https://hashmon-frontend.onrender.com
Frontend Static Site:
- URL:
https://hashmon-frontend.onrender.com - Env Var:
VITE_API_URL=https://hashmon-backend.onrender.com/api
After fixing, test the mint voucher creation again!