Function: proxyFetch()
proxyFetch(
doInstance,req,doBindingName,handler?,options?,proxyInstanceNameOrId?):Promise<string>
Defined in: src/proxyFetch.ts:33
Send a fetch request to be executed by a Worker via queue or ProxyFetchDO.
This function automatically detects which variant to use:
- If
PROXY_FETCH_DObinding exists → uses DO variant (lower latency) - If
PROXY_FETCH_QUEUEbinding exists → uses Queue variant (higher scalability)
The response is delivered later via a callback handler method on the DO, or not at all if handler is omitted (fire-and-forget).
Must be called from within a Durable Object as it uses ctx.id.
Parameters
doInstance
any
The Durable Object instance (pass this from within DO methods)
req
Request object or URL string to fetch
string | Request<unknown, CfProperties<unknown>>
doBindingName
string
Name of the DO binding for return routing
handler?
string
Optional name of the handler method on the DO to call with the response. If omitted, fire-and-forget mode (no callback).
options?
Optional configuration for timeout, retries, etc.
proxyInstanceNameOrId?
string
Returns
Promise<string>
Promise that resolves with the request ID when the request is enqueued
Throws
Error if handler is provided but doesn't exist as a method on the DO instance
Throws
Error if neither PROXY_FETCH_DO nor PROXY_FETCH_QUEUE binding is found