# Serve so4ag.json on your domain with a Cloudflare Worker

> Serve so4ag.json at the root of your domain with a Cloudflare Worker and choose between bundling the file and reading it from an HTTPS address.

Published: 2026-11-25 · SOQVER · https://soqver.com/blog/cloudflare-worker-so4ag-json-on-your-domain

By convention, `so4ag.json` belongs at the root of your domain, where many website platforms give you no way to put a file. The SO4AG Worker answers `/so4ag.json` in front of your website, while your website continues to answer every other address as before.

## What you need

Your domain’s DNS record must be proxied by Cloudflare, with the orange cloud switched on. A Worker route cannot run on a record set to `DNS only`. Check with your website platform first, since some hosted platforms require the proxy to be off.

You also need a Cloudflare account and Node.js 20 or newer if you deploy from the command line. Cloudflare’s documentation in November 2026 lists 100,000 requests per day on its free plan. The Worker is free, open source under Apache-2.0, and requires no SOQVER account. [Worker code and manual](https://github.com/soqvercom/so4ag/tree/main/cloudflare/so4ag-worker)

## Choose where the source lives

### Keep the file in the Worker

Use this option if your facts rarely change and you already keep them in a repository. Replace `so4ag.json` in the Worker folder with the source for your domain. When a fact changes, edit the file and deploy again.

### Read the source from an HTTPS address

Use this option if someone edits and confirms the facts elsewhere. Set `SOURCE_URL` to the HTTPS address that returns the source. The Worker reads it and keeps the last good copy so it can serve the file during a temporary outage.

For a source managed at SOQVER, use `https://soqver.com/s/YOUR-SOURCE/own/so4ag.json`. This address becomes available once the company confirms the source and enters its domain in the source settings. It returns the published revision with identifiers on the company’s domain. With the default refresh interval, a change published in the administration reaches your domain within about five minutes without a new deploy.

When the remote source has a signature and a key alongside it, the Worker can also answer `/so4ag.sig.json` and `/.well-known/so4ag-keys.json`. Add routes for those paths if you want to expose them on your domain.

## Deploy the Worker and add routes

From a checkout of the Worker folder, run these commands. The README also has a **Deploy to Cloudflare** button that copies the folder into your own repository and asks for the settings.

```sh
npm install
npx wrangler login
npx wrangler deploy
```

The first deployment gives you a preview address on `workers.dev`. To serve the file on your own domain, add the routes to `wrangler.jsonc` and run `npx wrangler deploy` again. Each route matches the host you write, so add a separate line for `www` if you serve both hosts. An example for Example Plumbing uses these routes.

```jsonc
{
  "routes": [
    { "pattern": "plumbing.example/so4ag.json", "zone_name": "plumbing.example" },
    { "pattern": "www.plumbing.example/so4ag.json", "zone_name": "plumbing.example" }
  ]
}
```

## Worker settings

| Variable | What it controls |
| --- | --- |
| `SOURCE_URL` | Leave empty to serve the file in the folder. Set an HTTPS address to read the source from there. |
| `DOMAIN` | The domain the source belongs to. Leave empty to use the domain the Worker runs on. |
| `REFRESH_SECONDS` | How long to serve a copy before reading the remote source again. Default `300`, minimum `60`. |
| `MAX_STALE_SECONDS` | How long to serve the last good copy while the remote source is unreachable. Default `604800` (seven days). Set `0` to turn this off. |

## What the Worker refuses to serve

The Worker checks that the document has `so4ag`, `id`, and `claims`, and that both the source and publisher identifiers belong to the domain it serves. It ignores a leading `www.` when comparing domains. For Example Plumbing, an example source ID is `https://plumbing.example/so4ag.json` and the publisher ID is `https://plumbing.example/#org`. If the domains differ, the Worker returns an error naming both, so you can spot a source configured for the wrong site.

A remote document that fails these checks is never served, even if the Worker has an older good copy. A `404` or `410` stops the Worker from serving the source. It falls back to the last good copy only when there is no response or the remote server returns `429` or a `5xx` status, and only within `MAX_STALE_SECONDS`.

## Check the result

Open `/so4ag.json` on your domain and inspect the `x-so4ag-worker` response header. It reports `embedded`, `fresh`, `cached`, `stale`, or `error`. The Worker checks the document structure and domain. Validate the full source before publishing. [Public validator](https://soqver.com/validator)

## What stays outside the Worker

- Add a **Facts and terms** page or a JSON-LD block to the website yourself if you want JSON-LD on a page.
- Assistants and search engines decide whether to use the facts.
- The business states the facts and is responsible for their accuracy.

## Next step

Check that your DNS record is proxied, then follow the deployment steps in the [Worker manual](https://github.com/soqvercom/so4ag/tree/main/cloudflare/so4ag-worker).
