The proxy is configured by Worker environment variables, optionally overlaid by
**central config** fetched from the CMP backend so you can change behaviour
without redeploying.

## Key environment variables

| Var                     | Purpose                                                                       |
| ----------------------- | ----------------------------------------------------------------------------- |
| `UPSTREAM`              | Base URL of the central Lightning Worker the proxy forwards `/v1/*` to.       |
| `PREFIX`                | First-party path prefix, e.g. `/__consent`.                                   |
| `COOKIE_GUARD`          | `on` to strip non-consented `Set-Cookie` headers.                             |
| `SCRIPT_GATE`           | `on` to auto-gate tracker `<script>` tags in origin HTML.                     |
| `COOKIE_MAP`            | JSON mapping cookie names → category (exact match, or `*` suffix for prefix). |
| `TRACKER_MAP`           | JSON mapping tracker hosts → category.                                        |
| `UNKNOWN_COOKIE_POLICY` | `keep` (default, fail-open) or `strip`.                                       |
| `ESSENTIAL_COOKIES`     | JSON array of cookie names always kept.                                       |
| `LICENSE_KEY`           | Your license key.                                                             |
| `EDGE_CONFIG_URL`       | Central config endpoint; overlays local env, edge-cached ~300s.               |

## Central config vs. local

Set `LICENSE_KEY` + `EDGE_CONFIG_URL` to manage the cookie/tracker maps centrally
(no redeploy on change), or configure everything locally via the env vars above.
A config-fetch failure **falls back to local env** — a bad fetch never takes the
site down.

## Updating

Two levers:

- **Behaviour/config** — change central config; picked up within the cache TTL,
  no redeploy.
- **Code** — a new `@lightning-cmp/edge-proxy` npm version is picked up on your
  next `wrangler deploy`.

:::caution[Fail-open by design]
An unclassified cookie is **kept** by default (`UNKNOWN_COOKIE_POLICY=keep`) so an
unexpected cookie never breaks your site. Tighten to `strip` only once you've
mapped your cookies.
:::

:::note[More detail coming]
Being migrated from `packages/edge-proxy/README.md`.
:::