Deploy to Vercel
Complete guide to deploying Chameleon on Vercel
Deploy to Vercel
Vercel is the recommended hosting platform for Chameleon, offering seamless Next.js deployment and Postgres database.
Prerequisites
- GitHub account
- Vercel account (sign up at vercel.com)
- Chameleon repository pushed to GitHub
Quick Deployment
Step 1: Import Project
- Go to vercel.com/new
- Click Import Project
- Select your GitHub repository
- Click Import
Step 2: Configure Project
Vercel will auto-detect Next.js settings. Keep defaults:
- Framework Preset: Next.js
- Root Directory:
./ - Build Command:
pnpm build - Output Directory:
.next - Install Command:
pnpm install
Click Deploy (will fail without environment variables, that's OK).
Step 3: Add Vercel Postgres
- In your Vercel project, go to Storage tab
- Click Create Database
- Select Postgres
- Choose a name (e.g., "chameleon-db")
- Select region (choose closest to your users)
- Click Create
Vercel automatically creates these environment variables:
POSTGRES_URLPOSTGRES_PRISMA_URLPOSTGRES_URL_NON_POOLING
Step 4: Set DATABASE_URL
- Go to Settings > Environment Variables
- Click Add New
- Add:
Name: DATABASE_URL Value: ${POSTGRES_URL} - Select environments: Production, Preview, Development
- Click Save
Using ${POSTGRES_URL} references the auto-created variable.
Step 5: Add Required Environment Variables
Add these variables one by one:
# Authentication
NEXTAUTH_SECRET="your-random-secret-32-chars"
AUTH_SECRET="your-random-secret-32-chars"
NEXTAUTH_URL="https://your-domain.vercel.app"
# Base URL
NEXT_PUBLIC_WEB_URL="https://your-domain.vercel.app"
# Admin
ADMIN_EMAILS="your-email@example.com"
Generate secrets:
# On Mac/Linux
openssl rand -base64 32
# On Windows (PowerShell)
-join ((48..57) + (65..90) + (97..122) | Get-Random -Count 32 | % {[char]$_})
Step 6: Add OAuth Providers (Optional)
Google OAuth:
AUTH_GOOGLE_ID="xxx.apps.googleusercontent.com"
AUTH_GOOGLE_SECRET="GOCSPX-xxx"
GitHub OAuth:
AUTH_GITHUB_ID="xxx"
AUTH_GITHUB_SECRET="xxx"
Setup OAuth:
- Add callback URL:
https://your-domain.vercel.app/api/auth/callback/google - Same for GitHub
Step 7: Add Stripe Keys (Optional)
STRIPE_PRIVATE_KEY="sk_test_xxx" # Use sk_live for production
STRIPE_PUBLISHABLE_KEY="pk_test_xxx" # Use pk_live for production
STRIPE_WEBHOOK_SECRET="whsec_xxx"
Webhook URL:
https://your-domain.vercel.app/api/pay/notify/stripe
Step 8: Add AI Provider Keys (Optional)
# Can be configured in UI at /admin/ai-config
OPENAI_API_KEY="sk-proj-xxx"
KLING_ACCESS_KEY="xxx"
SEEDANCE_API_KEY="xxx"
DEEPSEEK_API_KEY="sk-xxx"
REPLICATE_API_TOKEN="r8_xxx"
OPENROUTER_API_KEY="sk-or-xxx"
SILICONFLOW_API_KEY="sk-xxx"
AI keys can be configured in the admin panel after deployment. Environment variables are a fallback.
Step 9: Redeploy
- Go to Deployments tab
- Click Redeploy on the latest deployment
- Or push a new commit to trigger auto-deploy
Step 10: Run Database Setup
Option A: Vercel CLI (Recommended)
# Install Vercel CLI
npm install -g vercel
# Login
vercel login
# Link project
vercel link
# Pull environment variables
vercel env pull .env.local
# Run database setup (includes automatic initialization)
pnpm db:setup
Option B: Local with Connection String
# Get DATABASE_URL from Vercel dashboard
# Add to .env.local
DATABASE_URL="postgresql://xxx"
# Run database setup (includes automatic initialization)
pnpm db:setup
This command will:
- Create all database tables
- Automatically initialize the credit system
- Insert initial AI provider configurations (if environment variables are set)
- Set up price tier configurations
New Feature: The pnpm db:setup command automatically handles database initialization. No manual SQL scripts needed!
Step 11: Configure Admin System (Required)
Critical: Admin System configuration is required for the application to function properly. Without proper admin configuration, many features will not work.
11.1: Access Admin Panel
- Visit your deployed site:
https://your-project.vercel.app - Sign in with an email listed in
ADMIN_EMAILS - Visit
/admin- you should see the admin dashboard
11.2: Configure AI Providers (Required)
You MUST configure at least one AI provider to use AI generation features:
- Go to
/admin/ai-config - Click on a provider (e.g., OpenAI, Kling, Seedance)
- Enter the API key from your environment variables
- Toggle Enabled to ON
- Click Save
Recommended providers to start with:
- OpenAI - For text and image generation (most versatile)
- Seedance - For video generation (high quality)
- Kling - For image and video generation (good alternative)
Important: Without AI providers configured, the AI Generator will not work, even if you have API keys in environment variables. The Admin System configuration takes priority.
11.3: Verify Credit System
- Check that credit rules are properly initialized
- Verify price tier configurations are set up
- Test that users receive initial credits
Step 12: Verify Complete Deployment
Visit your deployed site:
https://your-project.vercel.app
Essential Checks:
- ✅ Homepage loads
- ✅ Sign in works
- ✅ Database connected
- ✅ Admin access works (
/admin) - ✅ AI providers configured (
/admin/ai-config) - ✅ AI Generator works (
/ai-generator) - ✅ Credit system functioning
Custom Domain
Add Custom Domain
- Go to Settings > Domains
- Enter your domain:
your-domain.com - Click Add
- Follow DNS configuration instructions
DNS Records (example for Cloudflare):
Type: A
Name: @
Content: 76.76.21.21
Type: CNAME
Name: www
Content: cname.vercel-dns.com
Update Environment Variables
After adding custom domain, update:
NEXTAUTH_URL="https://your-domain.com"
NEXT_PUBLIC_WEB_URL="https://your-domain.com"
Update OAuth Callbacks
Update callback URLs in:
- Google Cloud Console
- GitHub OAuth settings
- Any other OAuth providers
New callback format:
https://your-domain.com/api/auth/callback/google
https://your-domain.com/api/auth/callback/github
Update Stripe Webhook
Update webhook URL in Stripe Dashboard:
https://your-domain.com/api/pay/notify/stripe
Environment Variables Checklist
Use this checklist to ensure all variables are set:
Required ✅
-
DATABASE_URL -
NEXTAUTH_SECRET -
AUTH_SECRET -
NEXTAUTH_URL -
NEXT_PUBLIC_WEB_URL -
ADMIN_EMAILS
OAuth (Optional)
-
AUTH_GOOGLE_ID -
AUTH_GOOGLE_SECRET -
AUTH_GITHUB_ID -
AUTH_GITHUB_SECRET
Payment (Optional)
-
STRIPE_PRIVATE_KEY -
STRIPE_PUBLISHABLE_KEY -
STRIPE_WEBHOOK_SECRET
AI Providers (Optional)
-
OPENAI_API_KEY -
KLING_ACCESS_KEY -
SEEDANCE_API_KEY -
DEEPSEEK_API_KEY -
REPLICATE_API_TOKEN -
OPENROUTER_API_KEY -
SILICONFLOW_API_KEY
Other (Optional)
-
RESEND_API_KEY -
NEXT_PUBLIC_OPENPANEL_CLIENT_ID -
NEXT_PUBLIC_OPENPANEL_CLIENT_SECRET
Production Checklist
Before going live:
Security
- Use strong
NEXTAUTH_SECRET(32+ characters) - Switch to Stripe live keys (
sk_live_...) - Enable HTTPS only (automatic on Vercel)
- Set secure headers in
next.config.mjs - Review environment variable visibility
Performance
- Enable Vercel Analytics
- Configure caching headers
- Optimize images (automatic on Vercel)
- Monitor function execution times
Database
- Upgrade Vercel Postgres plan if needed
- Enable automatic backups
- Set up monitoring and alerts
- Review connection limits
Testing
- Test sign-in flow
- Test payment (use test card, then refund)
- Test AI generation
- Test mobile responsiveness
- Test different browsers
Monitoring
- Set up error tracking (Sentry, etc.)
- Configure uptime monitoring
- Set up Stripe Dashboard monitoring
- Review Vercel logs regularly
Common Issues
Build Failed
Error: "Module not found"
Solution:
# Clean local build
rm -rf .next node_modules
pnpm install
pnpm build
# If works locally, check Vercel build logs
Database Connection Error
Error: "Can't reach database server"
Solution:
- Check
DATABASE_URLis set correctly - Ensure Postgres database is created
- Use
${POSTGRES_URL}reference, not hardcoded value - Check database region matches your Vercel region
Environment Variable Not Working
Problem: Variable shows as undefined
Solution:
- Verify variable name (case-sensitive)
- Check variable is set for correct environment
- Redeploy after adding variables
- Check for typos or extra spaces
Stripe Webhook Failing
Error: "No signatures found matching the expected signature"
Solution:
- Get webhook secret from Stripe Dashboard
- Update
STRIPE_WEBHOOK_SECRETin Vercel - Ensure webhook URL is correct
- Redeploy
Function Timeout
Error: "Function execution timeout"
Solution:
- Upgrade to Vercel Pro (10s → 60s timeout)
- Optimize AI generation to use background jobs
- Use Edge Functions for faster response
AI Generator Not Working After Deployment
Symptoms: AI Generator shows no providers or generation fails
Solutions:
- Configure AI Providers: Visit
/admin/ai-configand ensure at least one provider is configured and enabled - Check Environment Variables: Verify AI provider API keys are set in Vercel environment variables
- Admin Access: Make sure you can access
/adminwith an email fromADMIN_EMAILS - Database Priority: Admin System configuration takes priority over environment variables
Admin Panel Access Issues
Symptoms: Can't access /admin or see "No access" message
Solutions:
- Check ADMIN_EMAILS: Make sure your email is in the
ADMIN_EMAILSenvironment variable in Vercel - Redeploy: Redeploy after adding
ADMIN_EMAILS - Email Match: Ensure the email you sign in with exactly matches the one in
ADMIN_EMAILS - Sign Out/In: Sign out and sign back in after admin configuration
Vercel Features
Automatic Deployments
- Every push to
mastertriggers deployment - Preview deployments for pull requests
- Instant rollback to previous deployments
Environment Variables Per Branch
- Production:
masterbranch - Preview: Pull requests and other branches
- Development: Local development
Analytics
Enable Vercel Analytics:
- Go to Analytics tab
- Click Enable
- View real-time traffic and performance
Logs
View logs in real-time:
- Go to Deployments
- Click on a deployment
- View Function Logs
- Filter by severity (Error, Warning, Info)
Cost Optimization
Free Tier
Vercel Free includes:
- 100 GB bandwidth
- 1000 serverless function invocations per day
- 100 GB-hours function execution
- Vercel Postgres: 256 MB storage, 60 hours compute
When to Upgrade
Consider Vercel Pro if:
- Traffic exceeds free tier limits
- Need longer function timeouts (video generation)
- Want automatic backups
- Need team collaboration
Alternative: Self-Hosted Database
Use external database instead of Vercel Postgres:
-
Choose provider:
- PlanetScale (MySQL)
- Supabase (PostgreSQL)
- Railway (Both)
- AWS RDS
-
Get connection string
-
Set in Vercel:
DATABASE_URL="postgresql://user:pass@host:5432/db" -
Run migration (from local)
Next Steps
- Environment Variables - Complete list
- Database Setup - Database guide
- Payment Setup - Stripe configuration
- Troubleshooting - Common issues