Files
linearvoid/docs/operations/cloudflare-workers-setup.md
T
zwitschi 9e56ff7859
CI / test (push) Successful in 2m55s
CI / docker (push) Successful in 46s
feat(ops): replace Cloudflare Pages with Workers for frontend hosting
2026-08-16 08:17:23 +02:00

4.1 KiB

Cloudflare Workers Setup — Linear Void

Linear Void uses Cloudflare Workers for two purposes:

Product Purpose What
Workers Static SPA hosting Vite-built frontend (frontend/dist) served as Worker static assets
Workers Edge cache logic infrastructure/cloudflare/worker.js — adds immutable cache headers to HLS segments

Both are managed under Workers & Pages in the Cloudflare dashboard.

Dashboard URLs

Resource URL
Workers & Pages overview https://dash.cloudflare.com/deb11491c54ec53a24772e98ac6d8128/workers-and-pages
Worker: linearvoid https://dash.cloudflare.com/deb11491c54ec53a24772e98ac6d8128/workers/services/view/linearvoid/production/settings
API tokens https://dash.cloudflare.com/profile/api-tokens

Worker: linearvoid (edge cache headers)

The Worker at infrastructure/cloudflare/worker.js runs on the linearvoid Workers service. It intercepts requests and adds immutable Cache-Control headers to .m4s segment files.

Deploy via Wrangler CLI:

npx wrangler deploy infrastructure/cloudflare/worker.js

Or paste into the Workers dashboard at the URL above (Quick Edit).

Worker: static frontend

Serve the Vite-built SPA (frontend/dist) as Worker static assets:

  1. Build the frontend: cd frontend && npm run build.
  2. Bind frontend/dist to the Worker as static assets (Workers Static Assets / assets in wrangler.toml).
  3. Attach the linearvoid.tv custom domain to the Worker.

See gitea-cloudflare-workers.md for the automated deployment workflow.

Variables and secrets

On the Worker, set the following environment variables (needed to run the frontend):

Type Name Value
Secret ADMIN_PASSWORD not-a-real-admin-password
Plaintext ADMIN_SESSION_TTL_HOURS 12
Plaintext ADMIN_USERNAME boogers
Plaintext HLS_SEGMENT_DURATION 2
Plaintext HLS_WINDOW_SIZE 12
Plaintext PLAYLIST_PATH /app/playlist/playlist.txt
Plaintext VITE_PUBLIC_ADMIN_DEFAULT_MODERATOR boogers
Plaintext VITE_PUBLIC_ADMIN_DEFAULT_ROOM main
Plaintext VITE_PUBLIC_ADMIN_MODERATION_LOG_LIMIT 50
Plaintext VITE_PUBLIC_APP_URL https://linearvoid.tv
Plaintext VITE_PUBLIC_HLS_URL https://media.linearvoid.tv/hls/playlist.m3u8
Plaintext VITE_PUBLIC_WS_URL wss://linearvoid.tv/ws

Custom domains

  • linearvoid.tv → Worker (static SPA)
  • www.linearvoid.tv → redirect to linearvoid.tv
  • media.linearvoid.tv → R2 bucket (separate; not a Worker)