Skip to content

createProxy

createProxy(input): object

Creates the site proxy. Its fetch serves the injected script at SCRIPT_PATH, forwards everything else under MOUNT_PREFIX to the tenant, and passes other requests to the site’s own server. For a GET answered 200 with HTML, it reads the page’s content facts, asks decide, and rewrites the page in one pass. When decide answers, the page is sent with cache-control: private, no-store.

const proxy = createProxy({ env, adapter });
export default { fetch: (request) => proxy.fetch(request) };

Build it once and reuse it: settings are read at construction, and their warnings are reported once rather than on every request. With a required setting missing, it serves the script and passes every other request through unmodified.

ProxyAdapter

Record<string, unknown>

object

fetch: (request) => Promise<Response>

Request

Promise<Response>