Fetches a Happ subscription URL with the required headers (User-Agent + X-HWID, which
a browser cannot send) and hosts the configs as a subscription at /sub/<token>.
- Cloudflare dashboard -> Workers & Pages -> Create -> Worker. Name it
happwn. - Edit code -> paste the contents of
worker.js-> Deploy. - Storage & Databases -> KV -> Create a namespace, e.g.
happwn-subs. - Worker -> Settings -> Bindings -> Add -> KV namespace: variable name
SUBS, selecthappwn-subs-> Save and deploy. - Copy the Worker URL (e.g.
https://happwn.<you>.workers.dev). - Open the site, go to Settings, and paste your Worker URL. Done — no code edits needed.
By default the worker accepts requests from any origin (ALLOWED_ORIGIN = "*"), so it
works with the official site and any fork out of the box. Set ALLOWED_ORIGIN to your
site origin in worker.js if you want to restrict browser callers.
cd worker
npm i -g wrangler
wrangler kv namespace create SUBS # paste the id into wrangler.toml
wrangler deployThen open the site, go to Settings, and paste the Worker URL.
POST /build— JSON{ subUrl?, configs?, userAgent, hwid }-> fetches/normalizes, stores a base64 subscription in KV (7-day TTL), returns{ token, url, count, configs }.GET /sub/<token>— returns the base64 subscription astext/plainfor any VPN client.
Guardrails: request body <= 256 KB, upstream body <= 1 MB, <= 5000 configs, http(s) only,
15s fetch timeout, CORS limited to the site origin.