Configuration Files
Environment variables are stored in two locations:.env(root) - Shared variables for web app, infrastructure, and Docker Composeapps/agent/.env- Agent-specific variables (worker configuration, proxies)
Quick Setup
Create environment files from examples:Database Configuration
Variables for PostgreSQL and ClickHouse database connections.PostgreSQL connection string for the main application database.Format: Example (Docker):
postgresql://[user]:[password]@[host]:[port]/[database]Example (local):Use
localhost for local development. Use service names (db) when running in Docker Compose.PostgreSQL username. Must match the username in
DATABASE_URL.Default: userPostgreSQL password. Must match the password in
DATABASE_URL.PostgreSQL database name. Must match the database in
DATABASE_URL.Default: mydbClickHouse HTTP interface URL for analytics data.Example (local):Example (Docker):
ClickHouse database name for analytics tables.Default:
analyticsClickHouse username for authentication.Default:
defaultClickHouse password for authentication.
Application URLs
Variables for configuring application URLs and routing.Internal server-side URL for the web application.Local development:Docker (internal):
This URL is used for server-to-server communication within the Docker network.
Base URL for internal API calls. Typically same as
APP_URL.Public-facing URL for Better Auth callbacks (client-side).Development:Production:
Public API URL exposed to the browser (Next.js public env var).Development:Production:
Variables prefixed with
NEXT_PUBLIC_ are exposed to the browser.Authentication & Secrets
Variables for authentication and security.Secret key for signing Better Auth session tokens.Generate a secure secret:
Secret for authenticating internal cron job requests.Generate:
Google OAuth client secret for Google authentication.
Redis Configuration
Variables for Redis queue and cache.Full Redis connection URL.Local development:With password:Docker:
Redis server hostname.Local:
localhost
Docker: redisRedis server port.Default:
6379Redis authentication password.
Agent Worker Configuration
Variables specific to the browser automation agent worker (set inapps/agent/.env).
Number of concurrent browser jobs the agent can process.Default:
1Higher values increase throughput but require more CPU and memory. Each worker runs a separate browser instance.
Path for storing browser authentication profiles and session data.Default: In Docker, this maps to the
/storageagent_storage volume.Proxy Configuration
Variables for configuring proxy usage in the agent worker.How the agent obtains proxy servers.Options:
auto- Automatically fetch from proxy APImanual- Read from a local filenone- Don’t use proxies
API endpoint to fetch proxy list (when
PROXY_SOURCE_MODE=auto).Path to file containing proxy list (when
PROXY_SOURCE_MODE=manual).Format: One proxy per line: host:port:username:passwordExternal APIs
Variables for third-party service integrations.Docker Configuration
GitHub Container Registry username for pulling Docker images.Used in
docker-compose.yml to construct image URLs:Debugging
Enable verbose debug logging.Default: Set to
falsetrue for detailed logs during development:Environment-Specific Configurations
Local Development
Minimal configuration for local development:.env
Docker Compose
Configuration for Docker Compose deployment:.env
Security Best Practices
-
Generate Strong Secrets
-
Use Strong Database Passwords
- Minimum 16 characters
- Mix of letters, numbers, and symbols
- Different passwords for each service
-
Never Commit Secrets
- Ensure
.envis in.gitignore - Use
.env.examplewith placeholder values - Rotate secrets regularly
- Ensure
-
Restrict Access
- Use environment-specific values
- Limit database user permissions
- Use read-only credentials where possible
-
Monitor API Keys
- Track OpenAI API usage
- Set up billing alerts
- Rotate keys periodically
-
Secure Redis
- Always set
REDIS_PASSWORDin production - Don’t expose Redis port publicly
- Use TLS for Redis in production
- Always set
Validation
Verify your environment configuration:Check required variables
Ensure all required variables are set and not using placeholder values like
changeme.Troubleshooting
Connection refused errors
Connection refused errors
Problem: Application can’t connect to services.Solution:
- For local dev, use
localhostin URLs - For Docker, use service names (
db,redis,clickhouse) - Ensure services are running:
docker compose ps
Authentication failed
Authentication failed
Problem: Database authentication errors.Solution:
- Verify credentials match in
DATABASE_URLandPOSTGRES_*variables - Check passwords don’t contain special characters that need URL encoding
- Recreate services:
docker compose down -v && docker compose up -d
Variables not updating
Variables not updating
Problem: Changes to
.env not taking effect.Solution:- Restart the application after changing
.env - For Docker:
docker compose down && docker compose up -d - Clear Next.js cache:
rm -rf apps/web/.next
Next Steps
Local Setup
Complete local development setup guide
Docker Compose
Learn about the Docker Compose architecture