Blog

Edge workers: run code on a domain route, update it and detach it

Create an edge worker on a panel domain, call it through its route, update its code, detach it from the domain and request its deletion. What a route does to the homepage.

Edge workers: run code on a domain route, update it and detach it

2026-11-29

Create and call

export default { async fetch(request, env) { return new Response('hello from an edge worker\n'); } };
  1. Open Edge Workers, or call create_edge_worker with a name, an ES module that has a default export, a compatibility date and a domain.
  2. The worker runs at once within the token's policy. Its routes are https://your-domain/_edge/name and https://your-domain/edge/name.
  3. Check it: curl -sS https://your-domain/_edge/name returns the text the worker returns.

Update and detach

  1. update_edge_worker changes the code and applies at once.
  2. update_edge_worker with domain set to null detaches the worker. Its route stops, and the domain's own homepage returns.
  3. delete_edge_worker waits for a person in Approvals. Nothing is removed until the owner approves.

Warning

A worker attached to a domain takes over that domain's homepage over HTTPS, so the static index.html stops showing there until the worker is detached. For tests, attach a worker to a subdomain that you do not use for anything else.

All posts