Vercel build is failing with a generic error because environment variables aren't set during the build process.
# On your local machine, generate a secure 32+ character secret
openssl rand -base64 32
# Copy the output - you'll need it in the next stepGo to your Vercel project dashboard:
- Settings → Environment Variables
- Add each variable below with your actual values:
| Variable | Value | Production Only? |
|---|---|---|
DATABASE_URL |
Your PostgreSQL connection string | ✅ |
NEXTAUTH_SECRET |
Generate with openssl rand -base64 32 |
✅ |
NEXTAUTH_URL |
Your production domain (e.g., https://app.yourdomain.com) |
✅ |
RAZORPAY_KEY_ID |
Your Razorpay API Key ID | ✅ |
RAZORPAY_KEY_SECRET |
Your Razorpay API Secret | ✅ |
REDIS_URL |
Your Redis connection string (optional) | ✅ |
NODE_ENV |
production |
✅ |
NEXT_PUBLIC_FIREBASE_API_KEY |
From Firebase console | ❌ |
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN |
From Firebase console | ❌ |
NEXT_PUBLIC_FIREBASE_PROJECT_ID |
From Firebase console | ❌ |
NEXT_PUBLIC_RAZORPAY_KEY_ID |
Razorpay public key | ❌ |
Note: Mark variables as "Production" only unless you also want them in Preview deployments.
Option A (Automatic):
git push origin mainOption B (Manual):
- Go to Vercel Dashboard
- Select your project
- Deployments tab
- Find the failed deployment
- Click Redeploy
- Watch the build logs in Vercel Dashboard
- Should complete in ~2-3 minutes
- ✅ Build succeeds with "Deployment Successful" message
Once deployed:
- Visit your production URL
- Should see the login page without database connection errors
- Check Vercel Analytics for any runtime errors
- Check Build Logs - Click the failed deployment to see detailed error
- Verify DATABASE_URL - Must be a valid PostgreSQL connection string
- Check NEXTAUTH_SECRET - Must be 32+ characters, no spaces
- Clear Cache - Settings → Git → Disconnect and reconnect repo
- Test Locally - Run
npm run buildlocally with same env vars
# Test local build with production settings
npm run build
# View build output
cat apps/user-app/.next/build-manifest.json
# Check environment setup
echo $DATABASE_URL
echo $NEXTAUTH_SECRET
# Generate new secret if needed
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"Status: This resolves the Vercel build failure. Deployment should now succeed.