Cloudflare deployment
Deploy the UI to Pages and the API to a Worker.
Overview
BeaconAuth supports a split deployment:
- Cloudflare Pages for the React UI.
- Cloudflare Worker (
crates/beacon-worker) for the API.
The two deployments share the same project name (name) in both wrangler.jsonc and
wrangler.workers.jsonc (CI enforces this).
Wrangler configs
wrangler.jsonc: Cloudflare Pages config (UI build output atdist/).wrangler.workers.jsonc: Cloudflare Worker config (wasm build output).
CI workflows
.github/workflows/deploy-cloudflare-pages.ymldeploys the UI..github/workflows/deploy-cloudflare-worker.ymldeploys the API worker and applies migrations.
Required secrets (Pages)
CLOUDFLARE_API_TOKENCLOUDFLARE_ACCOUNT_ID
Optional:
SENTRY_AUTH_TOKEN
Required secrets (Worker)
CLOUDFLARE_API_TOKENCLOUDFLARE_ACCOUNT_IDTURSO_PLATFORM_API_TOKENTURSO_ORG_SLUGTURSO_DB_NAME
Optional:
TURSO_GROUP(defaults todefault)CLOUDFLARE_WORKER_BASE_URL(defaults tohttps://<name>.pages.dev)CLOUDFLARE_WORKER_LIBSQL_URL(override libSQL URL instead of Turso API)CLOUDFLARE_WORKER_LIBSQL_AUTH_TOKENCLOUDFLARE_MIGRATIONS_API_TOKEN(used for/v1/admin/migrations/up)- OAuth provider secrets (see below)
Optional Worker secrets for OAuth
CLOUDFLARE_WORKER_GITHUB_CLIENT_IDCLOUDFLARE_WORKER_GITHUB_CLIENT_SECRETCLOUDFLARE_WORKER_GOOGLE_CLIENT_IDCLOUDFLARE_WORKER_GOOGLE_CLIENT_SECRETCLOUDFLARE_WORKER_MICROSOFT_CLIENT_IDCLOUDFLARE_WORKER_MICROSOFT_CLIENT_SECRETCLOUDFLARE_WORKER_MICROSOFT_TENANT
Single-origin routing (optional)
If you want the UI and API to share a single origin, this repository already supports it via the Nitro server entry.
- The server entry lives in
src/server.ts. - Nitro generates the Cloudflare Pages worker bundle (
_worker.js) automatically during build. No manual Pages worker entry file is required. - Ensure the Pages project has a service binding named
BACKENDpointing to your API worker (seewrangler.jsonc).
By default, the server entry proxies requests whose path starts with /api/, /v1/, or
/.well-known/ to env.BACKEND and serves the UI for everything else.
Notes
- The Worker deployment uses libSQL/Turso (set
LIBSQL_URLandLIBSQL_AUTH_TOKEN). - Migrations are applied via the Worker endpoint
POST /v1/admin/migrations/upin CI.