Whenever an HTTP request is made, a Request object is dispatched to your worker, then the generated Response is returned. The
Request object will include a
cf object.
Miniflare will log the method, path, status, and the time it took to respond.
If the Worker throws an error whilst generating a response, an error page
containing the stack trace is returned instead.
Dispatching Events
When using the API, the dispatchFetch function can be used to dispatch fetch
events to your Worker. This can be used for testing responses. dispatchFetch
has the same API as the regular fetch method: it either takes a Request
object, or a URL and optional RequestInit object:
When dispatching events, you are responsible for adding
CF-* headers โ
and the
cf object.
This lets you control their values for testing:
Upstream
Miniflare will call each fetch listener until a response is returned. If no
response is returned, or an exception is thrown and passThroughOnException()
has been called, the response will be fetched from the specified upstream
instead:
Was this helpful?
What did you like?
What went wrong?
Thank you for helping improve Cloudflare's documentation!