The key server can run on Cloudflare Workers instead of Docker. Workers deploy to 300+ edge locations, giving viewers sub-50ms key fetch latency worldwide — without managing containers.Documentation Index
Fetch the complete documentation index at: https://docs.blindcast.dev/llms.txt
Use this file to discover all available pages before exploring further.
When to use Workers
| Docker key server | Cloudflare Workers |
|---|---|
| Centralized deployment | Global edge deployment |
| SQLite or Postgres for leases | KV or Durable Objects for leases |
| Runs anywhere Docker runs | Runs on Cloudflare’s network |
| Bundled presign endpoint | Custom presign route (see below) |
| Best for: most deployments | Best for: global latency-sensitive apps |
Quick start
Install the keys package:Full example with authentication
Wrangler configuration
Endpoints
The Worker key server exposes:| Method | Path | Description |
|---|---|---|
GET | /keys/:contentId | Content key (16 raw bytes) |
GET | /keys/:contentId/:epoch | Epoch key (for key rotation) |
GET | /health | Health check |
The Worker key server does not include lease or presign endpoints. For leases, implement a KV-backed
LeaseStore (see below). For presigned uploads, add a custom presign route (see Presign Endpoint below).Leases on Workers
The in-memoryLeaseStore does not work on Workers — each isolate has independent memory and does not share state across requests. Use Cloudflare KV or Durable Objects instead.
KV-backed lease store
wrangler.toml:
Presign endpoint
The Docker key server bundles a presign endpoint for browser uploads. On Workers, you add a custom presign route alongside the key server. The Uploader SDK requires apresignUrl to upload encrypted segments from the browser.
Use aws4fetch, not the AWS SDK
Full Worker with presign
This example composescreateWorkerKeyServer() with a custom presign route for R2:
Wrangler configuration (with presign)
Deployment steps
- Install dependencies:
- Store secrets (one at a time — wrangler prompts for the value):
- Deploy:
- Verify:
How env works on Workers
Cloudflare injects env as the second argument to your Worker’s fetch handler. Values come from two sources:
[vars]inwrangler.toml— for non-sensitive configuration (bucket name, account ID, CORS origins)wrangler secret put— for sensitive values (master key, salt, R2 credentials). Stored encrypted, not in source control.
env.R2_BUCKET_NAME, env.MASTER_KEY, etc.
Differences from Docker
| Feature | Docker | Workers |
|---|---|---|
| Key derivation | HKDF-SHA-256 | HKDF-SHA-256 (identical) |
| Authentication | JWT via env vars | Custom authenticate callback |
| Leases | SQLite / Postgres | KV / Durable Objects |
| Presign endpoint | Built-in | Custom route (see above) |
| Database | Auto-migrated | Not applicable |
| Health check | GET /health | GET /health |
| Deployment | docker run | wrangler deploy |
Player configuration
The player connects to a Worker key server the same way as Docker — just point to the Worker URL:Storage: R2
Cloudflare R2 is S3-compatible object storage with no egress fees — ideal for serving encrypted video segments. When paired with Workers, it gives you a fully Cloudflare-native deployment.Create an R2 bucket
Enable public access
Encrypted segments need to be publicly readable so the player can fetch them:- r2.dev subdomain (simplest): Enable in R2 → your bucket → Settings → Public access. Segments are accessible at
https://<bucket>.<accountId>.r2.dev/<key>. - Custom domain (production): Add a CNAME record pointing to your R2 bucket under R2 → your bucket → Settings → Custom domains.
R2 API credentials
The presign endpoint above needs S3-compatible credentials:- Go to R2 → Manage R2 API Tokens → Create API Token
- Select Object Read & Write permission, scoped to your bucket
- Save the Access Key ID and Secret Access Key
- Store them as Worker secrets:
wrangler secret put R2_ACCESS_KEY_IDandwrangler secret put R2_SECRET_ACCESS_KEY
CORS for browser uploads
When the Uploader SDK uploads encrypted segments from the browser via presigned URLs, R2 must allow the cross-origin PUT request:blindcast upload and CDN Configuration.
When to choose Docker instead
Use the Docker key server when:- You prefer the bundled presign endpoint (Workers require a custom route — see above)
- You want SQLite or Postgres lease storage without custom code
- You’re already running containers and don’t need edge latency
- You need all endpoints in a single deployment