Overview
Reportr requires several environment variables to be configured for proper operation. Copy.env.example to .env and configure all required values.
Required Variables
Database
PostgreSQL connection string for the database. Used for direct connections.Format:
postgresql://username:password@host:port/databaseExample: postgresql://postgres:password@localhost:5432/seo_reportbotAlternative database URL used by Prisma for connection pooling (e.g., via Supabase or PgBouncer).If not specified, Prisma will use
DATABASE_URL.Authentication
Secret key used to encrypt NextAuth.js JWT tokens and session data.Generate with:
openssl rand -base64 32Example: your-nextauth-secret-hereThe canonical URL of your application. Used by NextAuth.js for redirects.Development:
http://localhost:3000Production: https://yourdomain.comPublic-facing URL accessible from the client-side. Must match
NEXTAUTH_URL.Example: http://localhost:3000Google OAuth & APIs
OAuth 2.0 Client ID from Google Cloud Console. Used for user authentication and API access.Get from: Google Cloud Console > APIs & Services > Credentials
OAuth 2.0 Client Secret from Google Cloud Console.Security: Never commit this to version control.
OAuth callback URL that Google redirects to after authentication.Example:
http://localhost:3000/api/auth/callback/googleImportant: Must match exactly with the URI configured in Google Cloud Console.API key for Google PageSpeed Insights API. Used to fetch performance metrics.Get from: Google Cloud Console > APIs & Services > Credentials > Create API Key
AI Services
API key for Anthropic’s Claude API. Used to generate AI-powered insights in reports.Get from: Anthropic ConsoleFormat:
sk-ant-...Queue System
REST API URL for Upstash Redis. Used for background job processing and queue management.Get from: Upstash Console after creating a Redis databaseExample:
https://us1-example.upstash.ioAuthentication token for Upstash Redis REST API.Security: Keep this secret and never expose in client-side code.
File Storage
Vercel Blob storage token for storing generated PDF reports.Get from: Vercel Dashboard > Storage > Blob > Create TokenFormat:
vercel_blob_rw_...Payment Processing (Optional)
Stripe
Stripe secret key for processing payments and managing subscriptions.Get from: Stripe Dashboard > Developers > API KeysDevelopment: Use test key
sk_test_...Production: Use live key sk_live_...Webhook signing secret for verifying Stripe webhook events.Get from: Stripe Dashboard > Developers > Webhooks > Add endpointFormat:
whsec_...PayPal
PayPal REST API client ID for payment processing.Get from: PayPal Developer Dashboard
PayPal REST API client secret.
PayPal environment mode.Options:
sandbox (development) or live (production)Default: sandboxWebhook ID for verifying PayPal webhook signatures in production.Get from: PayPal Developer Dashboard > Apps & Credentials > Webhooks
PayPal Plan IDs
Subscription plan IDs for different tiers. These are server-side only:Starter plan with trial period.
Starter plan without trial.
Professional plan with trial period.
Professional plan without trial.
Agency plan with trial period.
Agency plan without trial.
Public PayPal Plan IDs
Client-side accessible plan IDs (prefixed withNEXT_PUBLIC_):
Public version of Starter trial plan ID.
Public version of Starter direct plan ID.
Public version of Professional trial plan ID.
Public version of Professional direct plan ID.
Public version of Agency trial plan ID.
Public version of Agency direct plan ID.
Email Service
API key for Resend email service. Used for sending transactional emails.Get from: Resend DashboardFormat:
re_...Email address used as the sender for outgoing emails.Example:
[email protected]Note: Must be verified in Resend dashboard.Reply-to email address for user responses.Example:
[email protected]Security
Secret token for authenticating cron job requests. Prevents unauthorized execution.Generate with:
openssl rand -base64 32Example: PiVKrJew9gQyWTohW/LiUV3J+xZPFIC7UkXrqLXoFgI=Example .env File
Environment-Specific Configuration
Development
For local development:- Use
http://localhost:3000for all URL variables - Use Stripe test keys (
sk_test_...) - Use PayPal sandbox mode
- Database can be local PostgreSQL
Production
For production deployment:- Use your production domain for URL variables
- Use Stripe live keys (
sk_live_...) - Set PayPal mode to
live - Use a managed PostgreSQL service (Vercel Postgres, Supabase, etc.)
- Enable all security features
- Verify all webhook endpoints are configured
Security Best Practices
- Use strong secrets: Generate random strings for all secret keys
- Rotate credentials regularly: Update API keys and secrets periodically
- Limit access: Only share credentials with team members who need them
- Use environment-specific keys: Different keys for dev, staging, and production
- Monitor usage: Check API usage and logs for suspicious activity
Verifying Configuration
After setting up your environment variables:- Restart your development server
- Check the application logs for connection errors
- Test authentication by signing in with Google
- Verify database connectivity with
npm run db:studio - Test API integrations in the dashboard
Troubleshooting
Variable Not Loading
If an environment variable is not being recognized:- Verify the variable name matches exactly (case-sensitive)
- Restart your development server after changes
- Check for syntax errors in
.env(no spaces around=) - Ensure client-side variables start with
NEXT_PUBLIC_
Database Connection Failed
If database connection fails:- Verify
DATABASE_URLformat is correct - Check PostgreSQL is running
- Test connection with
psqlcommand - Ensure database exists:
createdb seo_reportbot
OAuth Errors
If Google OAuth fails:- Verify
GOOGLE_REDIRECT_URImatches Google Cloud Console configuration - Check
NEXTAUTH_URLandNEXT_PUBLIC_APP_URLare identical - Ensure Google OAuth consent screen is configured
- Verify all required scopes are enabled