Environment Setup

Matching environment variables across backend and frontend

Environment Setup

Both the backend and frontend need matching configuration to work together. This page shows which variables need to align.

Local Development

Backend (.env.local)

# Core
APP_ENV=dev
APP_SECRET=your-random-secret
DATABASE_URL=postgresql://app:pass@database:5432/app?serverVersion=16&charset=utf8
JWT_PASSPHRASE=your-jwt-passphrase
CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$

# Stripe
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_SUCCESS_URL=http://localhost:3000/payment/success
STRIPE_CANCEL_URL=http://localhost:3000/payment/cancel

# Firebase
FIREBASE_PROJECT_ID=your-firebase-project-id

# Frontend URLs
EMAIL_VALIDATION_REDIRECT_URL=http://localhost:3000/auth/email-verified
FRONTEND_RESET_PASSWORD_URL=http://localhost:3000/auth/reset-password

# Email (dev uses Mailpit)
MAILER_DSN=smtp://mailer:1025

Frontend (environment / docker-compose.yml)

NUXT_PUBLIC_API_BASE_URL=http://localhost
NUXT_PUBLIC_FIREBASE_API_KEY=your-firebase-api-key
NUXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
NUXT_PUBLIC_FIREBASE_PROJECT_ID=your-firebase-project-id

Production

Backend

APP_ENV=prod
APP_SECRET=production-secret
DATABASE_URL=postgresql://user:password@host:5432/dbname
JWT_PASSPHRASE=production-passphrase
CORS_ALLOW_ORIGIN=^https://yourdomain\.com$

STRIPE_SECRET_KEY=sk_live_...
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_SUCCESS_URL=https://yourdomain.com/payment/success
STRIPE_CANCEL_URL=https://yourdomain.com/payment/cancel

FIREBASE_PROJECT_ID=your-firebase-project-id

EMAIL_VALIDATION_REDIRECT_URL=https://yourdomain.com/auth/email-verified
FRONTEND_RESET_PASSWORD_URL=https://yourdomain.com/auth/reset-password

BREVO_API_KEY=xkeysib-...
EMAIL_SENDER_EMAIL=noreply@yourdomain.com
EMAIL_SENDER_NAME=Your App Name

Frontend

NUXT_PUBLIC_API_BASE_URL=https://api.yourdomain.com
NUXT_PUBLIC_FIREBASE_API_KEY=your-firebase-api-key
NUXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
NUXT_PUBLIC_FIREBASE_PROJECT_ID=your-firebase-project-id
NUXT_PUBLIC_UMAMI_HOST=https://analytics.yourdomain.com
NUXT_PUBLIC_UMAMI_ID=your-site-id

Variables That Must Match

ConcernBackend VariableFrontend Variable
API URL(the backend's own URL)NUXT_PUBLIC_API_BASE_URL
CORSCORS_ALLOW_ORIGIN(the frontend's own URL)
Firebase ProjectFIREBASE_PROJECT_IDNUXT_PUBLIC_FIREBASE_PROJECT_ID
Stripe SuccessSTRIPE_SUCCESS_URLMust point to frontend /payment/success
Stripe CancelSTRIPE_CANCEL_URLMust point to frontend /payment/cancel
Email ValidationEMAIL_VALIDATION_REDIRECT_URLMust point to frontend /auth/email-verified
Password ResetFRONTEND_RESET_PASSWORD_URLMust point to frontend /auth/reset-password

The key rule: all redirect URLs in the backend must point to valid frontend routes.