ProxyAdapter
ProxyAdapter =
object
What the platform supplies to createProxy.
Methods
Section titled “Methods”botCategory()
Section titled “botCategory()”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.
Parameters
Section titled “Parameters”request
Section titled “request”Request
Returns
Section titled “Returns”string | null
collectorFetch()?
Section titled “collectorFetch()?”
optionalcollectorFetch(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.
Parameters
Section titled “Parameters”request
Section titled “request”Request
Returns
Section titled “Returns”Promise<Response>
connectingIp()?
Section titled “connectingIp()?”
optionalconnectingIp(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.
Parameters
Section titled “Parameters”request
Section titled “request”Request
Returns
Section titled “Returns”string | null
decideFetch()?
Section titled “decideFetch()?”
optionaldecideFetch(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.
Parameters
Section titled “Parameters”request
Section titled “request”Request
Returns
Section titled “Returns”Promise<Response>
fetch()
Section titled “fetch()”fetch(
request):Promise<Response>
The platform’s fetch. The proxy uses it for the upstream site, the tenant and decide.
Parameters
Section titled “Parameters”request
Section titled “request”Request
Returns
Section titled “Returns”Promise<Response>
rewriter()
Section titled “rewriter()”rewriter():
ProxyRewriter
A new ProxyRewriter. The proxy may build several for one request.
Returns
Section titled “Returns”waitUntil()?
Section titled “waitUntil()?”
optionalwaitUntil(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.
Parameters
Section titled “Parameters”promise
Section titled “promise”Promise<unknown>
Returns
Section titled “Returns”void
warn()
Section titled “warn()”warn(
code,detail):void
Receives every ProxyWarning with its detail. It must not throw, because the proxy calls it from its own error handling.
Parameters
Section titled “Parameters”detail
Section titled “detail”Record<string, unknown>
Returns
Section titled “Returns”void