Files
mycode/jsonhero-web/SELF_HOSTING.md
2026-02-04 12:18:35 +08:00

1.2 KiB

Deploying to Cloudflare

Install and login to wrangler

npm install -g wrangler
wrangler login

Create service

Go to workers tab from your cloudflare profile and create a new worker. Use HTTP Handler as service type. The name of worker must match the name field in wrangler.toml.

Setup wrangler.toml

Edit the following variables in wrangler.toml and wrangler.toml.dev:

  • account_id: Get account id by using
    wrangler whoami
    
  • kv_namespaces: Run the following comands to create a new KV namespace.
    wrangler kv:namespace create DOCUMENTS # gives namespace id
    wrangler kv:namespace create DOCUMENTS --preview # gives preview id for namespace
    
    Replace current entry for kv_namespaces as:
    kv_namespaces = [
    { binding = "DOCUMENTS", id = <YOUR_ID>, preview_id = <YOUR_PREVIEW_ID> }
    ]
    

Configure Environment Variables

Set SESSION_SECRET environment for worker.

wrangler secret put SESSION_SECRET

Optionally set other secrets listed at the end of wrangler.toml.

Publish worker

wrangler publish