Configuration
This section covers the environment configuration required to run the Cosailor Template in different environments.
Security Best Practices for Secrets
- Never commit secrets to version control
- Use environment variables for all sensitive data
- Generate strong secrets:
# Generate a strong JWT secret or auth secret
openssl rand -hex 32
Web Frontend Configuration (Next.js)
- Client-side variables (
NEXT_PUBLIC_*) - Available in the browser - Server-side variables - Only available on the server
Required Environment Variables
Create a .env.local file in the apps/web directory:
# OAuth Configuration
AUTH_GOOGLE_ID=<your-google-oauth-client-id>
AUTH_GOOGLE_SECRET=<your-google-oauth-client-secret>
# Auth.js Configuration
AUTH_SECRET=<random-secret-string>
AUTH_TRUST_HOST=true
AUTH_URL=http://localhost:3000/api/auth
CORE_API_URL=http://localhost:8000
CHAT_API_URL=http://localhost:8001
OAuth Provider Setup
-
Google OAuth:
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URIs:
http://localhost:3000/api/auth/callback/google(development)http://yourdomain.com/api/auth/callback/google(production)
-
Auth.js Configuration:
AUTH_SECRET: Generate a random string (32+ characters recommended)AUTH_TRUST_HOST: Set totrueto trust the hostAUTH_URL: The base URL where your auth endpoints are served
Core API Configuration
Required Environment Variables
Create a .env file in the apps/core-api directory:
# Database Configuration
DATABASE_URL=postgresql://username:password@localhost:5432/cosailor_db
DB_SCHEMA=public
# JWT Configuration
CORE_API_JWT_SECRET=<your-jwt-secret-key>
Database Setup
-
Install PostgreSQL:
- PostgreSQL Download
- Create a database:
createdb cosailor_db
-
Run Migrations:
cd apps/core-api
DATABASE_URL="postgresql://..." alembic -c src/db/alembic.ini upgrade head -
Seed Test Data (Optional):
DATABASE_URL="postgresql://..." python src/scripts/seed_auth_data.py