Skip to content

Environment Variables

Configure Uranus with environment variables.

Configuration Methods

wrangler.toml

toml
[vars]
ENVIRONMENT = "production"
BROWSERBASE_PROJECT_ID = "your-project-id"

Cloudflare Dashboard

  1. Go to Workers & Pages
  2. Select your worker
  3. Settings > Variables
  4. Add environment variables

Secrets (Sensitive Data)

bash
# Add secret via CLI
npx wrangler secret put BROWSERBASE_API_KEY

Core Variables

ENVIRONMENT

Runtime environment identifier.

ValueDescription
developmentLocal development
stagingStaging environment
productionProduction 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_KEY

Authentication

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_KEY

Anthropic

bash
npx wrangler secret put ANTHROPIC_API_KEY

Resource 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-xxxxx

Note: Add .dev.vars to .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 deploy

Variable Reference

VariableRequiredDescription
ENVIRONMENTYesRuntime environment
BROWSERBASE_PROJECT_IDNoBrowser automation project
BROWSERBASE_API_KEYNoBrowser automation key
CF_ACCESS_AUDNoCloudflare Access audience

Secrets Management

Add Secret

bash
npx wrangler secret put SECRET_NAME

List Secrets

bash
npx wrangler secret list

Delete Secret

bash
npx wrangler secret delete SECRET_NAME

Secrets in CI/CD

yaml
- name: Set secrets
  run: |
    echo "${{ secrets.BROWSERBASE_API_KEY }}" | npx wrangler secret put BROWSERBASE_API_KEY

Best 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 authentication

4. Validate on Startup

Check required variables:

typescript
if (!env.DB) {
  throw new Error('DB binding is required')
}

Released under the MIT License.