Interface: RouteOptions
Defined in: packages/utils/src/route-do-request.ts:36
Configuration options for DO request routing and authentication hooks.
Properties
agentCompatibility?
optional
agentCompatibility:boolean
Defined in: packages/utils/src/route-do-request.ts:97
Add Agent/PartyKit compatibility headers to requests forwarded to the DO.
When true
, automatically adds these headers before forwarding:
x-partykit-namespace
: The DO binding name segment from the URLx-partykit-room
: The DO instance name or ID from the URL
These headers are required by Cloudflare's Agent
class (from the agents
package)
and PartyKit's Server
class (from the partyserver
package).
When enabled, prefix
defaults to 'agents'
(matching the agents package convention)
unless explicitly overridden.
Default
false
cors?
optional
cors:CorsOptions
Defined in: packages/utils/src/route-do-request.ts:80
CORS configuration for cross-origin requests.
false
(default): No CORS headerstrue
: Permissive mode - echo any request's Origin header{ origin: string[] }
: Whitelist of allowed origins{ origin: (origin: string, request: Request) => boolean }
: Custom validation function
For detailed examples and security considerations, see https://lumenize.com/docs/utils/cors-support
onBeforeConnect()?
optional
onBeforeConnect: (request
,context
) =>undefined
|void
|Response
|Request
<unknown
,CfProperties
<unknown
>> |Promise
<undefined
|void
|Response
|Request
<unknown
,CfProperties
<unknown
>>>
Defined in: packages/utils/src/route-do-request.ts:46
Hook called before WebSocket requests (Upgrade: websocket) reach the Durable Object.
Parameters
request
Request
The incoming WebSocket upgrade request
context
Routing context with DO namespace and instance identifier
doInstanceNameOrId
string
The instance name or unique ID from the URL path
doNamespace
any
The resolved DurableObjectNamespace for the binding
Returns
undefined
| void
| Response
| Request
<unknown
, CfProperties
<unknown
>> | Promise
<undefined
| void
| Response
| Request
<unknown
, CfProperties
<unknown
>>>
Response to block call to DO, Request to enhance request, undefined/void to continue
onBeforeRequest()?
optional
onBeforeRequest: (request
,context
) =>undefined
|void
|Response
|Request
<unknown
,CfProperties
<unknown
>> |Promise
<undefined
|void
|Response
|Request
<unknown
,CfProperties
<unknown
>>>
Defined in: packages/utils/src/route-do-request.ts:60
Hook called before non-WebSocket HTTP requests reach the Durable Object.
Parameters
request
Request
The incoming HTTP request
context
Routing context with DO namespace and instance identifier
doInstanceNameOrId
string
The instance name or unique ID from the URL path
doNamespace
any
The resolved DurableObjectNamespace for the binding
Returns
undefined
| void
| Response
| Request
<unknown
, CfProperties
<unknown
>> | Promise
<undefined
| void
| Response
| Request
<unknown
, CfProperties
<unknown
>>>
Response to block call to DO, Request to enhance request, undefined/void to continue
prefix?
optional
prefix:string
Defined in: packages/utils/src/route-do-request.ts:68
URL prefix that must be present before DO routing path.