The frontend is hosted on Lovable's servers but trying to reach http://localhost:3000, which only works on your local machine. You have two options:
git clone <YOUR_GIT_URL>
cd <YOUR_PROJECT_NAME>
npm install# In a separate terminal, start your Next.js backend
cd your-backend-folder
npm run dev
# Should be running on http://localhost:3000# In the project folder
npm run dev
# Will open on http://localhost:8080Now both frontend and backend are running locally and can communicate!
Deploy your Next.js backend to a hosting service:
- Vercel (recommended for Next.js)
- Railway
- Render
- Heroku
Example with Vercel:
cd your-backend-folder
vercel deploy
# Will give you a URL like: https://your-app.vercel.appCreate a .env file in your project root (or update environment variables in your hosting platform):
VITE_API_BASE_URL=https://your-app.vercel.appMake sure your backend accepts requests from your frontend domain:
// In your Next.js API middleware or next.config.js
const allowedOrigins = [
'https://your-frontend-domain.com',
'http://localhost:8080', // for local development
];
// Add CORS headers in your API routesVisit your backend health endpoint:
- Local: http://localhost:3000/api/auth/verify
- Production: https://your-app.vercel.app/api/auth/verify
Try creating an account in the app. Check browser console (F12) for:
API Base URL: http://localhost:3000
If you see errors like "Failed to fetch", your backend isn't reachable.
If you see CORS errors, add these headers to your backend API routes:
res.setHeader('Access-Control-Allow-Origin', allowedOrigin);
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');The app uses VITE_API_BASE_URL to determine where to send API requests:
| Environment | URL |
|---|---|
| Local Development | http://localhost:3000 |
| Production | https://your-backend.vercel.app |
Error: "Cannot connect to backend"
- ✅ Backend server is running
- ✅ API URL is correct
- ✅ CORS is configured
- ✅ Firewall/network allows the connection
Error: "401 Unauthorized"
- Token expired (re-login)
- Backend authentication is misconfigured
Error: "Failed to fetch"
- Backend not running
- Wrong API URL
- CORS blocking the request
- Local Testing: Run both frontend and backend locally
- Deploy Backend: Push backend to Vercel/Railway
- Update ENV: Set
VITE_API_BASE_URLto production URL - Test Production: Try all features on Lovable preview
- Check browser console (F12 → Console tab)
- Check network requests (F12 → Network tab)
- Verify backend logs
- Ensure Firebase credentials are set on backend