Miniflare allows you to run multiple workers in the same instance. All Workers can be defined at the same level, using the workers option.
Here's an example that uses a service binding to increment a value in a shared KV namespace:
Routing
You can enable routing by specifying routes via the API,
using the
standard route syntax.
Note port numbers are ignored:
When using hostnames that aren't localhost or 127.0.0.1, you
may need to edit your computer's hosts file, so those hostnames resolve to
localhost. On Linux and macOS, this is usually at /etc/hosts. On Windows,
it's at C:\Windows\System32\drivers\etc\hosts. For the routes above, we would
need to append the following entries to the file:
Alternatively, you can customise the Host header when sending the request:
When using the API, Miniflare will use the request's URL to determine which
Worker to dispatch to.
Durable Objects
Miniflare supports the script_name option for accessing Durable Objects
exported by other scripts. See
๐ Durable Objects
for more details.
Was this helpful?
What did you like?
What went wrong?
Thank you for helping improve Cloudflare's documentation!