Baseflare supports custom HTTP endpoints alongside the RPC system. UseDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nickruigrok/baseflare/llms.txt
Use this file to discover all available pages before exploring further.
httpRouter() to create a router and httpAction() to define handlers. The router dispatches incoming requests using exact path matching first, then longest-prefix matching as a fallback. Custom HTTP routes are processed after the built-in /api/query/, /api/mutation/, and /api/action/ routes. Pass the router to createWorker via the http field of the manifest.
httpRouter()
Creates and returns a new HttpRouter instance.
HttpRouter.route(config)
Registers an exact-path route. Exact matches always take priority over prefix matches.
The exact request path to match. Must start with
/. Example: '/webhooks/stripe'.The HTTP method to match (case-insensitive internally). Examples:
'GET', 'POST', 'PUT'.An
HttpAction created with httpAction().Error if the same method + path combination is registered twice.
HttpRouter.routeWithPrefix(config)
Registers a prefix route. When multiple prefix routes match a request path, the longest matching prefix wins.
The path prefix to match. Must start with
/. A request for /api/files/foo/bar
matches the prefix /api/files/.The HTTP method to match (case-insensitive).
An
HttpAction created with httpAction().Error if the same method + pathPrefix combination is registered twice.
HttpRouter.lookup(method, path)
Resolves a method and path to the registered handler. Checks exact routes first, then prefix routes sorted by descending prefix length. Returns null if no route matches.
lookup is called internally by createWorker for every incoming request. You
generally do not need to call it directly.httpAction(handler)
Wraps a handler function as an HttpAction suitable for passing to HttpRouter.route() or HttpRouter.routeWithPrefix().
The handler function. Receives the same
ActionCtx as an action() handler
(with ctx.runQuery, ctx.runMutation, ctx.runAction, ctx.auth, etc.) and
the raw Request object from the Cloudflare Workers runtime. Must return a
Response.HTTP Method Types
TheHttpMethod type exported from baseflare/server covers the standard set:
method parameter on route() and routeWithPrefix() accepts any string — it is not constrained to HttpMethod — to allow forwarding of non-standard methods. The comparison is case-insensitive.