Skip to content

Cloudflare Pages Deployment

Deploy Uranus to Cloudflare's edge network.

Prerequisites

  • Cloudflare account with Workers Paid plan (recommended)
  • Node.js 18+
  • Wrangler CLI

Quick Deploy

1. Install Dependencies

From the manage/ directory:

bash
npm install

2. Login to Cloudflare

bash
npx wrangler login

3. Create Resources

bash
# Create D1 database
npx wrangler d1 create agents-dashboard

# Create R2 bucket
npx wrangler r2 bucket create agents-dashboard-files

# Create Vectorize index
npx wrangler vectorize create agents-dashboard-embeddings \
  --dimensions=768 \
  --metric=cosine

4. Configure wrangler.toml

Update with your resource IDs:

toml
name = "cloudflare-agents-pages"
main = "src/worker.ts"
compatibility_date = "2024-12-05"
compatibility_flags = ["nodejs_compat"]

[build]
command = "npm run build"

[site]
bucket = "./dist"

[[d1_databases]]
binding = "DB"
database_name = "agents-dashboard"
database_id = "YOUR_DATABASE_ID"

[[r2_buckets]]
binding = "BUCKET"
bucket_name = "agents-dashboard-files"

[[vectorize]]
binding = "VECTORIZE"
index_name = "agents-dashboard-embeddings"

[[durable_objects.bindings]]
name = "AGENT"
class_name = "DashboardAgent"

[[migrations]]
tag = "v1"
new_classes = ["DashboardAgent"]

[[queues.producers]]
binding = "WORKFLOWS_QUEUE"
queue = "agents-dashboard-workflows"

[[queues.consumers]]
queue = "agents-dashboard-workflows"
max_batch_size = 10
max_batch_timeout = 30

[vars]
ENVIRONMENT = "production"

5. Apply Migrations

bash
# Main schema
npx wrangler d1 execute agents-dashboard --file=./schema.sql

# Migrations
npx wrangler d1 execute agents-dashboard --file=./migrations/002_multi_agent.sql
npx wrangler d1 execute agents-dashboard --file=./migrations/003_agent_auth.sql
npx wrangler d1 execute agents-dashboard --file=./migrations/004_workflow_executions.sql
npx wrangler d1 execute agents-dashboard --file=./migrations/005_cloudflare_settings.sql
npx wrangler d1 execute agents-dashboard --file=./migrations/006_browser_actions_types.sql
npx wrangler d1 execute agents-dashboard --file=./migrations/007_puppeteer_action_types.sql

6. Deploy

bash
npm run deploy

Cloudflare Resources

D1 Database

SQLite database at the edge:

toml
[[d1_databases]]
binding = "DB"
database_name = "agents-dashboard"
database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

R2 Storage

Object storage for files:

toml
[[r2_buckets]]
binding = "BUCKET"
bucket_name = "agents-dashboard-files"

Vectorize

Vector database for embeddings:

toml
[[vectorize]]
binding = "VECTORIZE"
index_name = "agents-dashboard-embeddings"

Durable Objects

Stateful compute:

toml
[[durable_objects.bindings]]
name = "AGENT"
class_name = "DashboardAgent"

[[migrations]]
tag = "v1"
new_classes = ["DashboardAgent"]

Queues

Async task processing:

toml
[[queues.producers]]
binding = "WORKFLOWS_QUEUE"
queue = "agents-dashboard-workflows"

[[queues.consumers]]
queue = "agents-dashboard-workflows"

Production Configuration

Environment Variables

toml
[vars]
ENVIRONMENT = "production"

# Optional: Browserbase
BROWSERBASE_PROJECT_ID = ""
BROWSERBASE_API_KEY = ""

# Optional: Cloudflare Access
CF_ACCESS_AUD = ""

Workers Paid Features

Recommended for production:

  • Unmetered requests
  • Longer CPU time
  • Durable Objects
  • Queues
  • Analytics

Monitoring

Cloudflare Dashboard

Monitor via Cloudflare dashboard:

  • Request analytics
  • Error rates
  • CPU time
  • Durable Object metrics

Logging

View logs:

bash
npx wrangler tail

Metrics

Enable Workers Analytics:

toml
[observability]
enabled = true

Scaling

Uranus automatically scales on Cloudflare:

  • Edge deployment worldwide
  • Automatic scaling
  • No cold starts (Durable Objects)
  • Pay-per-request

Troubleshooting

Deployment Failed

bash
# Check build
npm run build

# Verify wrangler config
npx wrangler whoami

# View detailed errors
npx wrangler deploy --verbose

D1 Connection Issues

bash
# Verify database
npx wrangler d1 list

# Test query
npx wrangler d1 execute agents-dashboard --command "SELECT 1"

Durable Object Errors

bash
# View DO logs
npx wrangler tail --filter "DO"

# Check migrations
npx wrangler migrations list

Rollback

Previous Version

bash
npx wrangler rollback

Specific Version

bash
npx wrangler rollback --version 12345

Security

Cloudflare Access

Enable SSO:

  1. Go to Cloudflare Access
  2. Create application
  3. Configure identity provider
  4. Set CF_ACCESS_AUD in wrangler.toml

API Security

  • Rate limiting enabled
  • CORS configured
  • HTTPS enforced

Cost Optimization

Free Tier Limits

ResourceLimit
Workers Requests100K/day
D1 Reads5M/day
D1 Writes100K/day
R2 Class A1M/month
R2 Class B10M/month

Consider Workers Paid ($5/month):

  • 10M requests included
  • Durable Objects
  • Queues
  • Longer CPU time