npm install -g wrangler
wrangler login
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
.
Edit the following variables in wrangler.toml
and wrangler.toml.dev
:
account_id
: Get account id by usingwrangler whoami
kv_namespaces
: Run the following comands to create a new KV namespace.Replace current entry forwrangler kv:namespace create DOCUMENTS # gives namespace id wrangler kv:namespace create DOCUMENTS --preview # gives preview id for namespace
kv_namespaces
as:kv_namespaces = [ { binding = "DOCUMENTS", id = <YOUR_ID>, preview_id = <YOUR_PREVIEW_ID> } ]
Set SESSION_SECRET
environment for worker.
wrangler secret put SESSION_SECRET
Optionally set other secrets listed at the end of wrangler.toml
.
wrangler publish