Current Error: HTTP 500 on /api/auth/guest
Deployment: https://ai-chatbot-ddk0f7ou8-al-wilsons-projects.vercel.app
Status: 🔴 CRITICAL - Users cannot access the app
The /api/auth/guest endpoint is failing because:
- It calls
createGuestUser()function - Which tries to insert into database using
drizzle(client) - The
clientis initialized withprocess.env.POSTGRES_URL - This environment variable is either missing or malformed in Vercel
Code Flow:
Guest button clicked
↓
/api/auth/guest route
↓
signIn("guest")
↓
authorize() in auth.ts
↓
createGuestUser() in queries.ts (LINE 66)
↓
db.insert(user).values({...})
↓
💥 DATABASE CONNECTION ERROR → 500
-
Go to: https://vercel.com/al-wilsons-projects/ai-chatbot/settings/environment-variables
-
Look for these 4 variables:
- DATABASE_URL
- POSTGRES_URL
- POSTGRES_PRISMA_URL
- POSTGRES_URL_NON_POOLING
-
Take a screenshot of what you see (we need to verify they're correct)
Click on each variable to see its value. Check if they match EXACTLY:
postgresql://postgres.iomzbddkmykfruslybxq:GZGLrGQV4bGRdrTZ@aws-0-us-east-1.pooler.supabase.com:6543/postgres?pgbouncer=true
Check for:
- ✅ Starts with
postgresql:// - ✅ Username:
postgres.iomzbddkmykfruslybxq - ✅ Password:
GZGLrGQV4bGRdrTZ - ✅ Host:
aws-0-us-east-1.pooler.supabase.com - ✅ Port:
6543 - ❌ NOT missing protocol
- ❌ NOT starting with just the password
postgresql://postgres:GZGLrGQV4bGRdrTZ@db.iomzbddkmykfruslybxq.supabase.co:5432/postgres
Check for:
- ✅ Starts with
postgresql:// - ✅ Username:
postgres(NOTpostgres.iomzbddkmykfruslybxq) - ✅ Password:
GZGLrGQV4bGRdrTZ - ✅ Host:
db.iomzbddkmykfruslybxq.supabase.co - ✅ Port:
5432
postgresql://postgres.iomzbddkmykfruslybxq:GZGLrGQV4bGRdrTZ@aws-0-us-east-1.pooler.supabase.com:6543/postgres?pgbouncer=true&connect_timeout=15
postgresql://postgres:GZGLrGQV4bGRdrTZ@db.iomzbddkmykfruslybxq.supabase.co:5432/postgres
Option A: Fix via Vercel Dashboard
-
Delete the broken variables:
- Click the "⋯" menu next to each variable
- Select "Remove"
- Confirm deletion
-
Add corrected variables:
- Click "Add New" button
- Name:
DATABASE_URL - Value: (paste EXACT value from above)
- Environment: Check ✅ Production
- Click "Save"
Repeat for all 4 variables.
-
Redeploy:
- Go to: https://vercel.com/al-wilsons-projects/ai-chatbot/deployments
- Click latest deployment
- Click "⋯" → "Redeploy"
- Wait 3-5 minutes
Option B: Fix via Vercel CLI (Faster)
# Install CLI if needed
npm i -g vercel@latest
# Login
vercel login
# Remove old variables (if they exist)
vercel env rm DATABASE_URL production
vercel env rm POSTGRES_URL production
vercel env rm POSTGRES_PRISMA_URL production
vercel env rm POSTGRES_URL_NON_POOLING production
# Add correct variables
vercel env add DATABASE_URL production
# When prompted, paste: postgresql://postgres.iomzbddkmykfruslybxq:GZGLrGQV4bGRdrTZ@aws-0-us-east-1.pooler.supabase.com:6543/postgres?pgbouncer=true
vercel env add POSTGRES_URL production
# When prompted, paste: postgresql://postgres:GZGLrGQV4bGRdrTZ@db.iomzbddkmykfruslybxq.supabase.co:5432/postgres
vercel env add POSTGRES_PRISMA_URL production
# When prompted, paste: postgresql://postgres.iomzbddkmykfruslybxq:GZGLrGQV4bGRdrTZ@aws-0-us-east-1.pooler.supabase.com:6543/postgres?pgbouncer=true&connect_timeout=15
vercel env add POSTGRES_URL_NON_POOLING production
# When prompted, paste: postgresql://postgres:GZGLrGQV4bGRdrTZ@db.iomzbddkmykfruslybxq.supabase.co:5432/postgres
# Redeploy
vercel --prodAfter redeployment completes:
-
Check build logs:
- Go to: https://vercel.com/al-wilsons-projects/ai-chatbot/deployments
- Click the latest deployment
- Click "Building" → "View Function Logs"
- Look for errors related to database connection
- Should see:
✓ Compiled successfully
-
Test the endpoint:
- Open new incognito window
- Go to: https://ai-chatbot-five-gamma-48.vercel.app
- Click "Continue as Guest"
- Expected: Redirects to chat interface
- If 500 still appears: Continue to Step 5
Get detailed error logs:
-
Go to: https://vercel.com/al-wilsons-projects/ai-chatbot/logs
-
Filter by:
- Deployment: Latest
- Function:
/api/auth/guest - Status: Error (500)
-
Look for error messages like:
ERR_INVALID_URLconnect ECONNREFUSEDpassword authentication faileddatabase "postgres" does not existtimeout
-
Take screenshot of error and share with Devin
Cause: Missing postgresql:// prefix
Fix: Verify variable starts with postgresql://
Cause: Wrong password in URL
Fix: Verify password is GZGLrGQV4bGRdrTZ
Cause: Wrong host or port
Fix: Verify pooled host uses port 6543, direct uses 5432
Cause: Serverless function using direct connection (port 5432)
Fix: Ensure DATABASE_URL and POSTGRES_PRISMA_URL use pooled (port 6543)
Cause: Old deployment cached
Fix:
# Force clean redeploy
vercel --prod --forceBefore saying "it's fixed", verify ALL of these:
-
DATABASE_URLexists in Production environment -
DATABASE_URLstarts withpostgresql:// -
DATABASE_URLuses port6543(pooled) -
POSTGRES_URLexists in Production environment -
POSTGRES_URLuses port5432(direct) - All 4 database variables present
- Latest deployment shows "Ready" status
- Build logs show "✓ Compiled successfully"
- No build errors in logs
- Function logs show no database errors
- Production URL loads: https://ai-chatbot-five-gamma-48.vercel.app
- "Continue as Guest" button visible
- Clicking button redirects to chat (no 500)
- Chat interface loads
- Can send a test message
Run this test to isolate the issue:
- Open browser console (F12)
- Go to production URL
- Run this in console:
fetch('https://ai-chatbot-five-gamma-48.vercel.app/api/auth/guest?redirectUrl=/')
.then(r => r.text())
.then(console.log)
.catch(console.error)What to look for:
- If you see HTML with "500" → Database connection failing
- If you get redirected → Guest auth working!
- If you see "CORS error" → Try from the actual site, not console
Escalation Steps:
-
Screenshot the following:
- Vercel environment variables page (blur sensitive values)
- Build logs (last 50 lines)
- Function logs showing the 500 error
- Browser console error (F12 → Console tab)
-
Try Supabase connection test:
- Go to: https://supabase.com/dashboard/project/iomzbddkmykfruslybxq
- Click "Database" → "Connection info"
- Verify connection strings match what you have in Vercel
- Test connection using "Test connection" button
-
Report to Devin with:
- "Environment variables are correct (screenshot attached)"
- "Build succeeds but runtime fails (logs attached)"
- "Exact error message from Vercel logs: [paste here]"
If you need to revert to a working deployment:
- Go to: https://vercel.com/al-wilsons-projects/ai-chatbot/deployments
- Find a deployment that was working before
- Click "⋯" → "Promote to Production"
- This will make that old deployment live again
| Step | Time | Status |
|---|---|---|
| Check environment variables | 2 min | ⏳ |
| Update if incorrect | 5 min | ⏳ |
| Redeploy | 3 min | ⏳ |
| Test guest auth | 1 min | ⏳ |
| Total | ~10 min | ⏳ |
You'll know it's fixed when:
- ✅ No 500 error on
/api/auth/guest - ✅ Clicking "Continue as Guest" redirects to chat
- ✅ Can send messages as guest user
- ✅ Vercel function logs show no database errors
- ✅ Build completes successfully with no warnings
Summary: The guest authentication is trying to create a user in the database, but the database connection is failing. Fix the POSTGRES_URL and DATABASE_URL environment variables in Vercel with the complete connection strings (including postgresql:// prefix), then redeploy.
⏱️ Priority: 🔴 CRITICAL - Blocking all users
🎯 Fix Time: 10 minutes if variables are wrong
Report back with environment variable screenshot if still failing!