Cloudflare Workers
Environment variable configuration for Cloudflare Workers deployment
This configuration is ideal for edge computing with global distribution and cost-effective scaling. Cloudflare Workers provide excellent performance with built-in CDN and edge computing capabilities.
🚀 Core Application Settings
Variable | Description | Example | Required |
---|---|---|---|
BETTER_AUTH_SECRET | Secret key for Better Auth session encryption | your-32-character-secret-key | ✅ |
BETTER_AUTH_URL | Base URL of your application | https://yourdomain.com | ✅ |
NEXT_PUBLIC_APP_URL | Public URL for client-side usage | https://yourdomain.com | ✅ |
📧 Email Configuration
Variable | Description | Example | Required |
---|---|---|---|
RESEND_API_KEY | API key for Resend email service | re_123456789 | ✅ |
RESEND_AUDIENCE_ID | Audience ID for newsletter functionality | aud_123456789 | ❌ |
🔐 OAuth Provider Settings
GitHub OAuth
Variable | Description | Example | Required |
---|---|---|---|
GITHUB_CLIENT_ID | GitHub App Client ID | Iv1.a629723d24c123456 | ❌ |
GITHUB_CLIENT_SECRET | GitHub App Client Secret | abc123def456ghi789jkl012 | ❌ |
Google OAuth
Variable | Description | Example | Required |
---|---|---|---|
GOOGLE_CLIENT_ID | Google OAuth Client ID | 123456789-abc123.apps.googleusercontent.com | ❌ |
GOOGLE_CLIENT_SECRET | Google OAuth Client Secret | GOCSPX-abc123def456ghi789 | ❌ |
💳 Payment Integration (Stripe)
Variable | Description | Example | Required |
---|---|---|---|
STRIPE_SECRET_KEY | Stripe secret key for server-side operations | sk_test_123... or sk_live_123... | ❌ |
STRIPE_WEBHOOK_SECRET | Webhook endpoint secret for Stripe events | whsec_123456789 | ❌ |
NEXT_PUBLIC_PRICE_ID_PRO_MONTHLY | Stripe price ID for monthly pro plan | price_123456789 | ❌ |
NEXT_PUBLIC_PRICE_ID_PRO_YEARLY | Stripe price ID for yearly pro plan | price_987654321 | ❌ |
NEXT_PUBLIC_PRICE_ID_LIFETIME | Stripe price ID for lifetime plan | price_555666777 | ❌ |
📁 Storage Configuration
Variable | Description | Example | Required |
---|---|---|---|
NEXT_PUBLIC_AVATARS_BUCKET_NAME | Cloudflare R2 bucket name for avatar uploads | my-app-avatars | ❌ |
☁️ Cloudflare-Specific Storage Settings
Variable | Description | Example | Required |
---|---|---|---|
STORAGE_ACCOUNT_ID | Cloudflare Account ID for R2 storage | a1b2c3d4e5f6g7h8i9j0 | ❌ |
STORAGE_REGION | Cloudflare R2 region | auto | ❌ |
STORAGE_ACCESS_KEY_ID | R2 access key ID | abc123def456ghi789 | ❌ |
STORAGE_SECRET_ACCESS_KEY | R2 secret access key | xyz789uvw456rst123 | ❌ |
STORAGE_ENDPOINT | R2 endpoint URL | https://a1b2c3d4e5f6g7h8i9j0.r2.cloudflarestorage.com | ❌ |
📝 Example wrangler.jsonc Environment
[env.production.vars]
BETTER_AUTH_SECRET = "your-32-character-secret-key-here"
BETTER_AUTH_URL = "https://yourdomain.com"
NEXT_PUBLIC_APP_URL = "https://yourdomain.com"
# Email Service
RESEND_API_KEY = "re_123456789"
RESEND_AUDIENCE_ID = "aud_123456789"
# OAuth Providers
GITHUB_CLIENT_ID = "Iv1.a629723d24c123456"
GITHUB_CLIENT_SECRET = "abc123def456ghi789jkl012"
GOOGLE_CLIENT_ID = "123456789-abc123.apps.googleusercontent.com"
GOOGLE_CLIENT_SECRET = "GOCSPX-abc123def456ghi789"
# Payment Processing
STRIPE_SECRET_KEY = "sk_live_123..."
STRIPE_WEBHOOK_SECRET = "whsec_123456789"
NEXT_PUBLIC_PRICE_ID_PRO_MONTHLY = "price_123456789"
NEXT_PUBLIC_PRICE_ID_PRO_YEARLY = "price_987654321"
NEXT_PUBLIC_PRICE_ID_LIFETIME = "price_555666777"
# Storage
NEXT_PUBLIC_AVATARS_BUCKET_NAME = "my-app-avatars"
STORAGE_ACCOUNT_ID = "a1b2c3d4e5f6g7h8i9j0"
STORAGE_REGION = "auto"
STORAGE_ACCESS_KEY_ID = "abc123def456ghi789"
STORAGE_SECRET_ACCESS_KEY = "xyz789uvw456rst123"
STORAGE_ENDPOINT = "https://a1b2c3d4e5f6g7h8i9j0.r2.cloudflarestorage.com"
📝 Example .env File (Development)
# Core Application
BETTER_AUTH_SECRET=your-32-character-secret-key-here
BETTER_AUTH_URL=http://localhost:3000
NEXT_PUBLIC_APP_URL=http://localhost:3000
# Email Service
RESEND_API_KEY=re_123456789
RESEND_AUDIENCE_ID=aud_123456789
# OAuth Providers
GITHUB_CLIENT_ID=Iv1.a629723d24c123456
GITHUB_CLIENT_SECRET=abc123def456ghi789jkl012
GOOGLE_CLIENT_ID=123456789-abc123.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-abc123def456ghi789
# Payment Processing
STRIPE_SECRET_KEY=sk_test_123...
STRIPE_WEBHOOK_SECRET=whsec_123456789
NEXT_PUBLIC_PRICE_ID_PRO_MONTHLY=price_123456789
NEXT_PUBLIC_PRICE_ID_PRO_YEARLY=price_987654321
NEXT_PUBLIC_PRICE_ID_LIFETIME=price_555666777
# Storage
NEXT_PUBLIC_AVATARS_BUCKET_NAME=my-app-avatars
STORAGE_ACCOUNT_ID=a1b2c3d4e5f6g7h8i9j0
STORAGE_REGION=auto
STORAGE_ACCESS_KEY_ID=abc123def456ghi789
STORAGE_SECRET_ACCESS_KEY=xyz789uvw456rst123
STORAGE_ENDPOINT=https://a1b2c3d4e5f6g7h8i9j0.r2.cloudflarestorage.com