Creating a Supabase Project
Sign up or log in
Go to supabase.com and create an account or log in
Create new project
- Click “New Project”
- Choose your organization or create a new one
- Enter a project name (e.g., “galey-cloud-prod”)
- Generate a strong database password (save this securely)
- Select a region close to your users
- Click “Create new project”
Project creation takes 1-2 minutes. The database password cannot be recovered, so save it securely.
Setting Up Authentication
Configure email authentication
- Navigate to Authentication → Providers in the Supabase dashboard
- Email provider should be enabled by default
- For production, enable “Confirm email” to verify user emails
- Set “Site URL” to your production domain (e.g.,
https://galey.example.com)
Configure redirect URLs
- Go to Authentication → URL Configuration
- Add your Vercel deployment URL to Redirect URLs:
- For local development, also add:
Running Database Migrations
Galey Cloud uses two main tables:albums and photos. The SQL migration scripts are located in scripts/ directory.
Migration 1: Create Albums Table
Migration 2: Create Photos Table
Verify Tables Created
Understanding Row-Level Security Policies
All tables have Row-Level Security (RLS) enabled to ensure users can only access their own data.Albums Table Policies
| Policy Name | Operation | Rule |
|---|---|---|
albums_select_own | SELECT | User can only read their own albums |
albums_insert_own | INSERT | User can only create albums for themselves |
albums_update_own | UPDATE | User can only update their own albums |
albums_delete_own | DELETE | User can only delete their own albums |
Photos Table Policies
| Policy Name | Operation | Rule |
|---|---|---|
photos_select_own | SELECT | User can only read their own photos |
photos_insert_own | INSERT | User can only upload photos for themselves |
photos_update_own | UPDATE | User can only update their own photos |
photos_delete_own | DELETE | User can only delete their own photos |
All policies use
auth.uid() = user_id to ensure authenticated users can only access their own data. This prevents data leaks even if there’s a bug in the application code.Getting API Keys
You’ll need two API keys for your application:Copy Project URL
Copy the Project URL (e.g.,
https://xxxxx.supabase.co)This will be used as NEXT_PUBLIC_SUPABASE_URLCopy anon/public key
Under Project API keys, copy the
anon public keyThis will be used as NEXT_PUBLIC_SUPABASE_ANON_KEYTesting the Connection
Before deploying, verify your Supabase setup works correctly:Test authentication
- Navigate to
http://localhost:3000/auth/sign-up - Create a test account
- Check Supabase dashboard → Authentication → Users to verify user was created
- Try logging in at
http://localhost:3000/auth/login
Optional: Database Indexes
For better performance with large datasets, add indexes:Troubleshooting
”JWTExpired” errors
- Check that your Site URL and Redirect URLs are configured correctly
- Ensure cookies are enabled in your browser
- Verify the JWT expiry settings in Authentication → Settings
”Row-level security policy violation”
- Verify the user is authenticated before making database requests
- Check that
user_idis set correctly when inserting records - Review RLS policies in Authentication → Policies
”Failed to fetch” errors
- Verify your
NEXT_PUBLIC_SUPABASE_URLis correct - Check browser console for CORS errors
- Ensure Supabase project is active (not paused)
Next Steps
Environment Variables
Set up all required environment variables
Vercel Deployment
Deploy your application to Vercel