Environment Variables
Configure Uranus with environment variables.
Configuration Methods
wrangler.toml
toml
[vars]
ENVIRONMENT = "production"
BROWSERBASE_PROJECT_ID = "your-project-id"Cloudflare Dashboard
- Go to Workers & Pages
- Select your worker
- Settings > Variables
- Add environment variables
Secrets (Sensitive Data)
bash
# Add secret via CLI
npx wrangler secret put BROWSERBASE_API_KEYCore Variables
ENVIRONMENT
Runtime environment identifier.
| Value | Description |
|---|---|
development | Local development |
staging | Staging environment |
production | Production deployment |
toml
[vars]
ENVIRONMENT = "production"Browser Automation
BROWSERBASE_PROJECT_ID
Browserbase project identifier for browser automation.
toml
[vars]
BROWSERBASE_PROJECT_ID = "proj_xxxxx"BROWSERBASE_API_KEY
Browserbase API key (use secrets).
bash
npx wrangler secret put BROWSERBASE_API_KEYAuthentication
CF_ACCESS_AUD
Cloudflare Access audience tag for JWT validation.
toml
[vars]
CF_ACCESS_AUD = "your-access-audience-tag"AI Providers
Store API keys as secrets:
OpenAI
bash
npx wrangler secret put OPENAI_API_KEYAnthropic
bash
npx wrangler secret put ANTHROPIC_API_KEYResource Bindings
D1 Database
toml
[[d1_databases]]
binding = "DB"
database_name = "agents-dashboard"
database_id = "your-database-id"R2 Storage
toml
[[r2_buckets]]
binding = "BUCKET"
bucket_name = "agents-dashboard-files"Vectorize
toml
[[vectorize]]
binding = "VECTORIZE"
index_name = "agents-dashboard-embeddings"Durable Objects
toml
[[durable_objects.bindings]]
name = "AGENT"
class_name = "DashboardAgent"Queues
toml
[[queues.producers]]
binding = "WORKFLOWS_QUEUE"
queue = "agents-dashboard-workflows"Local Development
.dev.vars
Create .dev.vars for local secrets:
BROWSERBASE_API_KEY=your-dev-key
OPENAI_API_KEY=sk-dev-xxxxxNote: Add
.dev.varsto.gitignore
wrangler.toml [env.development]
toml
[env.development]
vars = { ENVIRONMENT = "development" }
[env.development.d1_databases]
[[env.development.d1_databases]]
binding = "DB"
database_name = "agents-dashboard-dev"
database_id = "your-dev-database-id"Environment-Specific Config
Development
toml
[env.development]
name = "uranus-dev"
[env.development.vars]
ENVIRONMENT = "development"Staging
toml
[env.staging]
name = "uranus-staging"
[env.staging.vars]
ENVIRONMENT = "staging"Production
toml
[env.production]
name = "uranus"
[env.production.vars]
ENVIRONMENT = "production"Deploy to Environment
bash
# Development
npx wrangler deploy --env development
# Staging
npx wrangler deploy --env staging
# Production (default)
npx wrangler deployVariable Reference
| Variable | Required | Description |
|---|---|---|
ENVIRONMENT | Yes | Runtime environment |
BROWSERBASE_PROJECT_ID | No | Browser automation project |
BROWSERBASE_API_KEY | No | Browser automation key |
CF_ACCESS_AUD | No | Cloudflare Access audience |
Secrets Management
Add Secret
bash
npx wrangler secret put SECRET_NAMEList Secrets
bash
npx wrangler secret listDelete Secret
bash
npx wrangler secret delete SECRET_NAMESecrets in CI/CD
yaml
- name: Set secrets
run: |
echo "${{ secrets.BROWSERBASE_API_KEY }}" | npx wrangler secret put BROWSERBASE_API_KEYBest Practices
1. Use Secrets for Sensitive Data
Never put API keys in wrangler.toml:
bash
# Good
npx wrangler secret put API_KEY
# Bad - never do this
[vars]
API_KEY = "sk-xxxxx"2. Environment Separation
Use different resources per environment:
toml
[env.development.d1_databases]
database_name = "agents-dashboard-dev"
[env.production.d1_databases]
database_name = "agents-dashboard"3. Document Variables
Keep a reference of required variables:
# Required Variables
ENVIRONMENT - Runtime environment
DB - D1 database binding
BUCKET - R2 bucket binding
# Optional Variables
BROWSERBASE_* - Browser automation
CF_ACCESS_AUD - SSO authentication4. Validate on Startup
Check required variables:
typescript
if (!env.DB) {
throw new Error('DB binding is required')
}