Environment Variables
Reportr requires several environment variables for database connections, authentication, API integrations, and third-party services.Quick Reference
Copy
.env.example from the repository root to get started:Required Variables
These variables are required for the application to function:Database
PostgreSQL connection string for direct database access (migrations)
Parameters:
Connection string format
Connection string format
sslmode=require- Enforce SSL connectionconnect_timeout=10- Connection timeout in seconds
PostgreSQL connection string with connection pooling (runtime queries)
Authentication
Random secret for encrypting JWTs and session tokens
Generate secure secret
Generate secure secret
Public URL of your application
Vercel automatically sets this in production. Only required for local development.
Client-side accessible app URL (same as NEXTAUTH_URL)
Variables prefixed with
NEXT_PUBLIC_ are accessible in browser JavaScript.Google OAuth & APIs
Google OAuth client ID for authentication
Setup instructions
Setup instructions
- Go to Google Cloud Console
- Create or select a project
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URI:
https://yourdomain.com/api/auth/callback/google
Google OAuth client secret
OAuth callback URL for Google authentication
Google PageSpeed Insights API key for performance data
Create API key
Create API key
- Go to Google Cloud Console
- Click Create Credentials → API Key
- Enable PageSpeed Insights API
- Restrict key to PageSpeed Insights API only (recommended)
AI Services
Anthropic Claude API key for generating report insights
Get API key
Get API key
- Sign up at console.anthropic.com
- Go to API Keys
- Create a new API key
- Copy and store securely
Queue System
Upstash Redis REST API URL for background job queue
Upstash Redis authentication token
Setup Upstash Redis
Setup Upstash Redis
- Go to console.upstash.com
- Create a new Redis database
- Select region closest to your deployment
- Copy REST URL and REST Token from database details
File Storage
Vercel Blob Storage token for PDF file uploads
Create Blob token
Create Blob token
- Go to vercel.com/dashboard/stores
- Create a new Blob store
- Link to your project
- Copy the read-write token
Email Service
Resend API key for sending transactional emails
Sender email address for transactional emails
Must be a verified domain in Resend dashboard.
Reply-to email address for customer responses
Optional Variables
These variables are optional but enable additional features:Payment Processing
PayPal REST API client ID for subscription payments
PayPal REST API client secret
PayPal environment mode
PayPal webhook ID for signature verification
Get webhook ID
Get webhook ID
- Go to PayPal Developer Dashboard
- Navigate to Apps & Credentials → Webhooks
- Create webhook with URL:
https://yourdomain.com/api/webhooks/paypal - Select event types:
BILLING.SUBSCRIPTION.CREATEDBILLING.SUBSCRIPTION.UPDATEDBILLING.SUBSCRIPTION.CANCELLEDPAYMENT.SALE.COMPLETED
- Copy the Webhook ID
PayPal Plan IDs
These configure subscription plans:Starter plan with 7-day trial
Starter plan without trial
Professional plan with 7-day trial
Professional plan without trial
Agency plan with 7-day trial
Agency plan without trial
Client-Side PayPal Plan IDs
These are duplicates of server-side plan IDs but accessible in browser JavaScript (prefixed with
NEXT_PUBLIC_).Alternative Payment (Stripe)
Stripe secret key (alternative to PayPal)
Stripe webhook signing secret
Cron Job Security
Secret token for authenticating cron job requests
Generate cron secret
Generate cron secret
This prevents unauthorized access to cron endpoints like
/api/cron/process-cancellations.Environment-Specific Configuration
Development (.env.local)
Production (.env.production)
Setting Variables in Vercel
Via Dashboard
Add variable
Click Add and enter:
- Key: Variable name (e.g.,
DATABASE_URL) - Value: Variable value
- Environment: Select Production, Preview, or Development
Via CLI
Validation
Reportr validates required environment variables at build time:Security Best Practices
Use different values per environment
- Development: Use test/sandbox credentials
- Production: Use live credentials
- Rotate production secrets regularly
Limit access to production variables
Use Vercel team permissions to restrict who can view/edit production environment variables.
Monitor for exposed secrets
Use tools like:
- GitGuardian - Scan for exposed secrets
- GitHub Secret Scanning - Automatic detection
Deployment Checklist
Before deploying to production, verify:Database
Database
-
DATABASE_URLpoints to production database -
PRISMA_DATABASE_URLuses connection pooling - Database migrations have been run
- Backups are configured
Authentication
Authentication
-
NEXTAUTH_SECRETis unique and secure (32+ chars) -
NEXTAUTH_URLmatches production domain -
GOOGLE_REDIRECT_URIis configured in Google Console - OAuth callback URLs are whitelisted
APIs & Integrations
APIs & Integrations
-
ANTHROPIC_API_KEYhas sufficient credits -
PAGESPEED_API_KEYis restricted to PageSpeed API -
UPSTASH_REDIS_REST_URLand token are valid -
BLOB_READ_WRITE_TOKENhas correct permissions -
RESEND_API_KEYdomain is verified
Payments
Payments
-
PAYPAL_MODEis set tolive - PayPal plan IDs are for production plans
-
PAYPAL_WEBHOOK_IDis configured - Webhook endpoint is publicly accessible
Security
Security
-
CRON_SECRETis set for cron endpoints - No secrets are committed to Git
- Production values differ from development
- Access to variables is restricted
Troubleshooting
Variable not found at runtime
Variable not found at runtime
Error:
process.env.VARIABLE_NAME is undefinedSolutions:- Check variable is set in Vercel dashboard
- Ensure correct environment (Production/Preview/Development)
- Redeploy application after adding variable
- For client-side variables, use
NEXT_PUBLIC_prefix
Database connection fails
Database connection fails
Error:
Can't reach database serverSolutions:- Verify
DATABASE_URLformat is correct - Check database is accessible from Vercel IPs
- Use
PRISMA_DATABASE_URLwith connection pooling - Ensure database credentials are correct
OAuth redirect mismatch
OAuth redirect mismatch
Error:
redirect_uri_mismatchSolutions:- Match
GOOGLE_REDIRECT_URIexactly in Google Console - Include
http://orhttps://in URI - No trailing slashes in callback URL
- Case-sensitive matching required
PayPal webhook signature verification fails
PayPal webhook signature verification fails
Error:
Webhook signature verification failedSolutions:- Verify
PAYPAL_WEBHOOK_IDis correct - Check webhook URL in PayPal dashboard matches deployment
- Ensure
PAYPAL_MODEmatches webhook environment (sandbox/live) - Verify webhook events are enabled
Additional Resources
Vercel Deployment
Deploy to Vercel with environment variables
Database Setup
Configure PostgreSQL database
.env.example
View complete example file
Vercel Env Docs
Official Vercel documentation