Edge Routing · Cloudflare

Install on Cloudflare from the dashboard

Create a Hello World Worker and paste the NORG edge router into the browser editor. No terminal and no Git connection.

1

Get your SITE_ID and NORG_SITE_KEY

The worker needs two values that tie it to your NORG site. Get them before you start, because the install asks for both.

  • SITE_ID: identifies your site in NORG. It is not secret.
  • NORG_SITE_KEY: the secret the worker uses to talk to NORG. It is shown once. NORG stores only a hash, so copy it straight away.

Option A: ask your AI assistant (NORG MCP)

With the NORG connector, ask for the edge site's status. It returns the SITE_ID. Then ask it to rotate the site key to mint a fresh NORG_SITE_KEY. Rotating asks you to confirm first: reply yes, and the new key is shown once.

If the site does not exist yet, ask it to convert the workspace to Sitemap Mirror mode for your domain. That creates the site and starts the first crawl. The Deploy button never changes the site's mode, it only deploys the worker. Free workspaces mirror up to 10 pages, and the cap cannot be raised once the site exists, so say so if you want the full mirror.

Option B: have NORG provide them

Ask your NORG contact. We will send the SITE_ID and a freshly minted NORG_SITE_KEY.

Rotating later: rotating invalidates the old key at once. A worker already running starts getting 401 responses from NORG until you put the new key into its secret and redeploy. It never breaks your site in the meantime: the worker falls back to serving your pages unchanged.

2

Create a Worker

In Cloudflare, open Workers & Pages and click Create application. Choose the account that holds your zone.

Workers & Pages with Create application highlighted
Workers & Pages, then Create application.

Under Make something new, choose Start with Hello World!

Make something new, with Start with Hello World highlighted
Choose Start with Hello World!

Name the worker norg-edge-router (it must be unique in your account) and click Deploy. This is only a placeholder. The next steps replace its code.

Deploy Hello World with the worker name and Deploy button highlighted
Name it norg-edge-router, then click Deploy.
3

Replace the code with the NORG worker

On the worker's page, click Edit code.

Worker overview with Edit code highlighted
The new worker is live. Click Edit code.

Select everything in worker.js (Ctrl/Cmd A) and delete it.

Browser editor with the Hello World code selected
The Hello World code is 17 lines. Select all of it (Ctrl/Cmd A) and delete it.
Empty browser editor
The editor is empty, with just line 1.

Open the worker file in a new browser tab. It is one self-contained file. Select all (Ctrl/Cmd A), copy (Ctrl/Cmd C), then paste into the empty editor (Ctrl/Cmd V).

https://raw.githubusercontent.com/norgai/norg-edge-mirror-cloudflare-deploy/main/src/edge-router-worker.js
The NORG worker source file open in a browser tab
The worker file open in its own tab. Select all (Ctrl/Cmd A) and copy (Ctrl/Cmd C).
Editor after pasting, starting GENERATED by build.mjs
After pasting, line 1 reads: GENERATED by build.mjs - do not edit.

Scroll to the bottom to check the whole file arrived. The screenshots here are worker version 0.15.3, which is 1363 lines long and ends with edge_router_worker_default as default then };. Later versions may add or remove lines, so the exact line numbers will change. What matters is that the file ends the same way and nothing is cut off.

End of the pasted file at line 1363
Scroll to the bottom to check the whole file arrived. In version 0.15.3 the last line is 1363.
4

Deploy the code

Click Deploy at the top right. A Version saved message confirms it.

Deploy button highlighted
Click Deploy, top right.
Version saved message
Version saved confirms the deploy.

Then click the worker name at the top left to leave the editor.

Back link to norg-edge-router highlighted
Click the worker name, top left, to leave the editor.
5

Add SITE_ID and NORG_SITE_KEY

Open the worker's Settings tab and click Add variable under Runtime variables and secrets.

Settings tab with Add variable highlighted
Settings, then Add variable under Runtime variables and secrets.

In the dialog, keep Production ticked and add two variables:

  • SITE_ID with your SITE_ID. Leave Secret unticked.
  • NORG_SITE_KEY with your key. Tick Secret so it is hidden.

Click Add 2 variables and deploy.

Add environment variable dialog with SITE_ID and NORG_SITE_KEY
Add both variables for Production. Tick Secret on NORG_SITE_KEY only.

Then add the schedule

The worker reports in every 30 minutes, so a site with little traffic still shows as alive. In Settings, scroll to Trigger events. Under Cron triggers, click Add.

Trigger events with the cron triggers Add button highlighted
Still in Settings, scroll to Trigger events. Under Cron triggers, click Add.

Leave it on Schedule, choose Minute(s), enter 30 and click Add. (The Cron expression tab takes */30 * * * *, the same thing.)

Cron triggers dialog set to every 30 minutes
Choose Minute(s), enter 30, then click Add.

Click Save. The worker's overview then lists the trigger.

Unsaved changes bar with Save highlighted
Click Save on the Unsaved changes bar.
Worker overview with Triggers showing */30 * * * *
The overview now shows Triggers 1 with */30 * * * *.
6

Attach the worker to your hostname

Deploying does not send any traffic to the worker. You attach it yourself. The hostname must be proxied (orange cloud) in Cloudflare DNS, or the worker never runs.

Open the worker, then Domains and Add Route. Choose the Zone and enter the Route as your hostname followed by /*, for example www.example.com/*. Click Add Route.

Domains tab with Add Route highlighted
Domains tab, then Add Route.
Add Route dialog
Choose the zone and enter your hostname followed by /*.

Mirroring a whole subdomain space rather than one hostname? Use Add Domain (a custom domain) instead of a route.

Failed to add domain error
Failed to add domain: see the checks below.

Failed to add domain? Another Worker is probably already using that route or domain, so they conflict. Find it under the zone's Workers Routes, then remove it or point it somewhere else. If your own Worker must keep serving the hostname, see installing alongside your own Worker.

Route listed under Custom Domains and Routes
The route now lists against the worker.
7

Add route exclusions

Static assets such as scripts, styles and images do not need the worker. An exclusion is a Cloudflare route that points at no worker, so requests to those paths skip it. NORG cannot add exclusions for this install because it holds no Cloudflare token, so you add them yourself.

  1. Open your zone, then Workers Routes and Add route.
  2. Enter a path prefix as the Route, for example www.example.com/_next/*.
  3. Open the Worker dropdown and choose None, then Save.
  4. Repeat for each prefix your site serves assets from, such as /_next/*, /_vercel/* or /static/*.
Zone Workers Routes page with Add route highlighted
Zone, Workers Routes, Add route.
Add route dialog for an exclusion
Enter the excluded path, then open the Worker dropdown and choose None.

Check the list afterwards: every exclusion should read Workers are disabled on this route, next to your one hostname/* route that names the worker.

Dashboard quick search for Workers & Pages
Ctrl/Cmd K, type Workers, pick Workers & Pages to get back to your worker.
8

Test that it works

1. The normal site. Open your site in a browser. It must look and behave exactly as before.

The customer site loading normally
A normal browser visit looks exactly as before.

2. The AI mirror. Add ?agent=true to the address, for example https://www.example.com/?agent=true. It should load the NORG AI-optimised version of the page. If it still shows your normal page, the worker is not on the route yet: recheck the route and that the hostname is proxied.

3. Invocations. Back in Cloudflare, open Workers & Pages, then your worker. The Invocations tile should now be above zero and rise as you reload the page. That confirms what you saw in the browser.

Worker overview showing invocations
Invocations counts the requests the worker has handled.
9

Turn on observability

Open the worker's Observability tab and click Enable Observability. Logs then show every request the worker handles, which is the quickest way to see what it is doing.

Observability tab with Enable Observability
Observability tab, then Enable Observability.
  • Free plan: we recommend enabling it. There is a daily cap on logs, and events past it are dropped rather than billed.
  • Paid plan: enable it, but watch the cost. Each request is a log event and logs beyond the plan's allowance are billed, so a busy site adds up. Lower the sampling rate to cap it, and check Cloudflare's current Workers pricing.
  • Switch it off once the install has run smoothly for about a month. The worker keeps working without logging.