Skip to main content

Deploying the Worker

Most deploys are automatic. Allegro uploads the current worker bundle to the organization's Cloudflare account, activates it, and syncs the property's routes. You can also deploy from the property's settings, or by hand with Wrangler when you need settings Allegro doesn't manage.

What a Deploy Does​

For one property, a deploy:

  1. Uploads the bundle as a new version of the worker allegro-edge-{organization}-{property}, creating the script on its first deploy.
  2. Sets the worker's variables and the EDGE_KEY secret (see below).
  3. Activates the new version for 100% of traffic.
  4. Creates or updates the route {hostname}/* to the worker, creates the exclusion routes, and deletes any of this worker's routes that are no longer needed, such as those for an old hostname.

Deploys for the same property never run at the same time. A deploy is skipped when the live worker already runs the same release with the same configuration, unless someone clicks Deploy now.

Worker Variables and Secret​

NameTypeValue
ALLEGRO_ORIGINvarThe property's Allegro base URL, used to call the evaluate endpoint.
PROPERTYvarThe property slug.
EDGE_HOSTNAMEvarThe hostname the worker serves. Requests for any other host pass through.
COOKIE_DOMAINvarThe property's cookie domain, falling back to the organization's.
EDGE_KEYsecretA per-property key the worker sends to Allegro to prove its identity.

EDGE_KEY is generated once per property and stored encrypted. Allegro uses it to decide whether to trust the visitor IP and location the worker forwards.

Exclusion Routes​

Static and admin paths never invoke the worker. Allegro creates a route with no worker for each of these patterns on the property's hostname:

/wp-content/*, /wp-includes/*, /wp-admin/*, /wp-json/*, /wp-login.php, /xmlrpc.php, /feed*, /build/*, /favicon.ico, /robots.txt

The worker passes these paths and any non-HTML response through on its own, so a missing exclusion route costs a worker invocation but doesn't change the response.

Automatic Deploys​

With EDGE_AUTO_DEPLOY on, deploys start on their own when:

  • edge:release records a new bundle during an Allegro deploy.
  • An organization connects Cloudflare, saves an API token, or picks an account.
  • A property's Edge settings are saved. Turning Enabled off removes the worker's routes instead.
  • The nightly retry at 04:00 runs, for properties whose last deploy failed.

Release rollouts and the nightly retry skip organizations that turned off Update automatically, have no Cloudflare connection, or don't have the Allegro Edge package enabled. A failed deploy is not retried until the nightly run.

Deploy and Roll Back from the Dashboard​

The Deployment card on the property's Edge settings shows the live release, whether it is Up to date or some number of releases behind, and the last ten deployments with what triggered each one: New release, Settings change, Manual deploy, Rollback, or Automatic retry.

  • Deploy now deploys the current release immediately, even when the configuration hasn't changed and even with EDGE_AUTO_DEPLOY off. It's disabled until Cloudflare is connected and Edge is enabled.
  • Roll back on an earlier successful deployment re-activates that worker version in Cloudflare and records a rollback.
Rollbacks don't touch routes

A rollback restores the worker code and variables of the earlier version only. If the hostname changed since then, routes stay on the current hostname.

Deploy, rollback, and the Edge settings are also available as MCP tools for AI clients.

Deploying by Hand​

Use a manual deploy for local testing, or when you need worker variables Allegro doesn't set (see Tuning Variables). A hand-deployed worker is replaced the next time Allegro deploys the property, so turn off Update automatically for the organization first.

  1. Print the property's worker configuration inside its tenant:

    php artisan tenants:artisan "edge:worker-config my-site" --tenant=example-tenant

    The command fails if the property doesn't exist, has Edge off, or has no hostname. It prints the worker name, account_id, [vars], and [[routes]] blocks, the command to set the secret, and the exclusion patterns.

  2. Copy the printed name, account_id, [vars], and [[routes]] over the placeholders in packages/allegro-edge/worker/wrangler.toml.

  3. Log in and deploy from packages/allegro-edge/worker:

    npx wrangler login
    npx wrangler deploy
  4. Set the edge key with the line the command printed:

    echo "<edge key>" | npx wrangler secret put EDGE_KEY
  5. Create each exclusion route once with the Cloudflare API, since wrangler.toml can't declare a route with no worker:

    curl -X POST https://api.cloudflare.com/client/v4/zones/<zone-id>/workers/routes \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"pattern":"www.acme.com/wp-admin/*"}'

Don't commit the filled-in wrangler.toml.