The frontend (hosted on Vercel at proteinarchi.tech) is trying to connect to localhost:8000 instead of the Render backend URL. This causes the error: "Cannot connect to backend server. Please make sure the backend is running on http://localhost:8000".
- Missing Environment Variable:
VITE_API_URLnot set in Vercel - Hardcoded URLs: Two endpoints in
PPIPrediction.jsxuse hardcodedhttp://localhost:8000 - Missing API Endpoints:
predict_ppi_from_sequencesandgenerate_ppi_videonot in API config
Goal: Confirm backend is deployed and get the URL
Actions:
- Go to Render dashboard: https://dashboard.render.com
- Find your backend service (likely named
genlab-backendor similar) - Check deployment status:
- ✅ Should show "Live" status
- ✅ Should have a URL like
https://genlab-backend-xxxx.onrender.com
- Test the backend health endpoint:
- Open:
https://your-backend-url.onrender.com/health - Should return:
{"status": "healthy"}
- Open:
- Record your backend URL for next steps
If backend is not deployed:
- Follow
RENDER_QUICK_SETUP.mdto deploy - Make sure all environment variables are set in Render dashboard
- Wait for deployment to complete (usually 2-5 minutes)
Goal: Replace hardcoded localhost:8000 with config-based URLs
Files to Fix:
frontend/src/components/PPIPrediction.jsx(2 locations)
Changes Needed:
- Add missing endpoints to
frontend/src/config/api.js - Update
PPIPrediction.jsxto useAPI_ENDPOINTSinstead of hardcoded URLs
Goal: Configure frontend to use Render backend URL
Actions:
- Go to Vercel dashboard: https://vercel.com/dashboard
- Select your project (likely
proteinarchitector similar) - Go to Settings → Environment Variables
- Add new variable:
- Key:
VITE_API_URL - Value:
https://your-backend-url.onrender.com(from Step 1) - Environment: Select all (Production, Preview, Development)
- Key:
- Click Save
- Redeploy your frontend:
- Go to Deployments tab
- Click ⋯ (three dots) on latest deployment
- Click Redeploy
- Or push a new commit to trigger redeploy
- Vercel environment variables starting with
VITE_are exposed to the browser - Make sure your backend URL is correct (HTTPS, not HTTP)
- After adding the variable, you MUST redeploy for changes to take effect
Goal: Ensure backend allows requests from Vercel frontend
Check Backend Code (backend/main.py):
- Lines 85-89: In production, CORS should allow all origins (
["*"]) - This is already configured correctly! ✅
Verify in Render:
- Check Render logs for CORS errors
- If you see CORS errors, verify:
ENVIRONMENT=productionis set in Render environment variablesFRONTEND_URLis set (optional, but recommended)- Backend is detecting production mode correctly
Goal: Verify frontend can connect to backend
Testing Steps:
- After redeploying Vercel, open your website:
https://proteinarchi.tech - Open browser console (F12 → Console tab)
- Check API configuration log:
- Should see:
🔧 API Configuration: { VITE_API_URL: 'https://...', API_URL: 'https://...', ... } - If
VITE_API_URLshowsNOT SET, the environment variable wasn't set correctly
- Should see:
- Try the research feature:
- Go to Research tab
- Enter a protein ID (e.g.,
P01308) - Check console for network requests
- Should see requests to
https://your-backend-url.onrender.com/research_protein
- Check for errors:
- If you see CORS errors → Check Step 4
- If you see 404 errors → Check backend URL is correct
- If you see connection timeout → Check Render backend is running
Solution:
- Verify environment variable is set in Vercel
- Make sure variable name is exactly
VITE_API_URL(case-sensitive) - Redeploy after adding the variable
- Check Vercel deployment logs to confirm variable is included
Solution:
- Verify
ENVIRONMENT=productionin Render - Check Render logs for CORS middleware initialization
- Backend should log:
🌐 Production mode: Allowing all origins for CORS
Solution:
- Verify backend URL is correct (check Render dashboard)
- Test backend health endpoint directly in browser
- Check backend logs in Render for route registration
Solution:
- First request after 15 min inactivity takes ~30 seconds
- This is normal for Render free tier
- Consider using a ping service (e.g., cron-job.org) to keep it awake
- Or upgrade to paid tier for always-on service
Solution:
- Check browser network tab for actual request URL
- Verify the request is going to Render URL, not localhost
- Clear browser cache and hard refresh (Ctrl+Shift+R / Cmd+Shift+R)
- Check if backend is actually running in Render dashboard
After completing all steps, verify:
- Render backend is deployed and shows "Live" status
- Backend health endpoint works:
https://your-backend.onrender.com/health -
VITE_API_URLis set in Vercel environment variables - Vercel frontend has been redeployed after adding environment variable
- Browser console shows correct
VITE_API_URL(notNOT SET) - No hardcoded
localhost:8000URLs in frontend code - Research feature works when entering a protein ID
- Network requests in browser show requests to Render URL (not localhost)
- No CORS errors in browser console
- Backend logs in Render show successful requests
If you just want to fix it quickly:
- Get your Render backend URL from Render dashboard
- Add to Vercel: Settings → Environment Variables →
VITE_API_URL=https://your-backend.onrender.com - Redeploy Vercel frontend
- Fix hardcoded URLs in
PPIPrediction.jsx(see Step 2) - Test the research feature
- Monitor Render logs for any backend errors
- Set up ping service (optional) to keep Render backend awake
- Consider upgrading Render to paid tier if you need always-on service
- Add error monitoring (e.g., Sentry) to catch issues early
- Document your backend URL for future reference
frontend/src/config/api.js- API configurationfrontend/src/components/PPIPrediction.jsx- Needs URL fixesfrontend/src/components/layout/SearchBar.jsx- Uses API_ENDPOINTS correctlybackend/main.py- Backend CORS configurationRENDER_QUICK_SETUP.md- Render deployment guide
- Development vs Production:
- Development: Uses
localhost:8000(from vite.config.js proxy) - Production: Uses
VITE_API_URLenvironment variable
- Development: Uses
- Environment Variables:
- Vite only exposes variables prefixed with
VITE_to the browser - Must redeploy after adding/changing environment variables
- Vite only exposes variables prefixed with
- Render Free Tier:
- Apps sleep after 15 minutes of inactivity
- First request after sleep takes ~30 seconds (cold start)
- Consider upgrading if you need faster response times