Visit: http://localhost:3000/api/health
This will show you:
- ✅ If environment variables are set correctly
- ✅ If the database connection is working
- ❌ Any specific errors preventing connection
Error: "Missing Supabase environment variables"
Solution:
- Check that
.env.localexists in the project root - Ensure it contains:
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY=your_supabase_publishable_key - Restart your dev server after adding/changing environment variables
Error: "relation 'public.users' does not exist" or similar
Solution:
- Go to your Supabase Dashboard → SQL Editor
- Copy the contents of
lib/supabase/migrations.sql - Paste and run it in the SQL Editor
- This creates all necessary tables, indexes, and RLS policies
Issue: You have DATABASE_URL and DIRECT_URL but the app needs:
NEXT_PUBLIC_SUPABASE_URL(not DATABASE_URL)NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY(this is your anon/publishable key)
Solution:
NEXT_PUBLIC_SUPABASE_URL= Your Supabase project URL (found in Settings → API)NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY= Your Supabase anon/publishable key (found in Settings → API)
Note: DATABASE_URL and DIRECT_URL are for direct PostgreSQL connections (like Prisma), not for the Supabase client library.
Error: "new row violates row-level security policy"
Solution:
- The migrations.sql file sets up RLS policies
- Make sure you've run the complete migrations.sql file
- Check in Supabase Dashboard → Authentication → Policies that policies exist
-
Get your Supabase credentials:
- Go to https://supabase.com/dashboard
- Select your project
- Go to Settings → API
- Copy:
- Project URL →
NEXT_PUBLIC_SUPABASE_URL - anon/public key →
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY
- Project URL →
-
Create
.env.localfile:NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY=your-anon-key-here
-
Run database migrations:
- Go to Supabase Dashboard → SQL Editor
- Copy contents of
lib/supabase/migrations.sql - Paste and execute
-
Test the connection:
- Visit
http://localhost:3000/api/health - Should show "Database connection successful"
- Visit
-
Restart your dev server:
npm run dev
After setup, you should be able to:
- ✅ Sign up new users
- ✅ Sign in with email/password
- ✅ Sign in with Google (if configured)
- ✅ Create properties
- ✅ Create and sign contracts
If any of these fail, check the browser console and the /api/health endpoint for specific error messages.