Skip to content

ProxyAdapter

ProxyAdapter = object

What the platform supplies to createProxy.

botCategory(request): string | null

The platform’s verified-bot category for this request, such as request.cf.verifiedBotCategory on Cloudflare, or null. Return null when the platform cannot verify bots. No bot then bypasses decide, which is safer than trusting a user agent.

Request

string | null


optional collectorFetch(request): Promise<Response>

Sends the post that records experiment exposures instead of ProxyAdapter.fetch. Supply it with ProxyAdapter.decideFetch, for the same reason: on the tenant host’s own zone the platform’s fetch does not reach the collector, such as a Cloudflare service binding to the collector Worker. Without it there, no exposure is recorded.

Request

Promise<Response>


optional connectingIp(request): string | null

The IP the platform saw the connection from, such as cf-connecting-ip on Cloudflare, or null. Matched against EDGEKIT_BYPASS_IPS. Omit it when the platform does not stamp one: no IP then bypasses decide. Never read a header the caller could have written.

Request

string | null


optional decideFetch(request): Promise<Response>

Sends the proxy’s own decide call instead of ProxyAdapter.fetch. Supply it when the tenant host is on the same zone as this proxy and the platform’s fetch cannot reach it, such as a Cloudflare service binding to the decide Worker. Requests under /edgekit/ from the browser are unaffected.

Request

Promise<Response>


fetch(request): Promise<Response>

The platform’s fetch. The proxy uses it for the upstream site, the tenant and decide.

Request

Promise<Response>


rewriter(): ProxyRewriter

A new ProxyRewriter. The proxy may build several for one request.

ProxyRewriter


optional waitUntil(promise): void

Keeps promise alive after the response is returned, such as ctx.waitUntil on Cloudflare. The proxy hands it the post that records a decision’s experiment exposures; the promise never rejects. Omit it on a platform that lets an unawaited request finish on its own. It must not throw.

Promise<unknown>

void


warn(code, detail): void

Receives every ProxyWarning with its detail. It must not throw, because the proxy calls it from its own error handling.

ProxyWarning

Record<string, unknown>

void

edgekit.ai