The Miniflare docs now include a migration guide for upgrading from version 1.
Breaking Changes
- Mounts are no longer accessible by default via
/<mount_name>
. You must specify routes inwrangler.toml
using theroute
/routes
/miniflare.route
/miniflare.routes
options for them to be accessible. See 🔌 Multiple Workers for more details. This feature was inspired bymultiflare
, created by @dan-lee. - All file-path-valued options are now resolved relative to the
--root
option Miniflare#dispatchFetch
will now rewrite the request's URL/Host
header to match the upstream URL if specifiedconvertNodeRequest
no longer accepts anupstream
parameter, it now always uses the request'sHost
header
Features
- Make
Request
/Response
body
s byte streams, allowing them to be read with bring-your-own-buffer readers - Allow setting the
wrangler.toml
environment when mounting workers with the CLI. For example,--mount api=./api@dev
mounts the worker in the./api
directory asapi
, using thedev
environment in./api/wrangler.toml
. - Allow setting the Durable Object
script_name
option via the CLI. For example,--do COUNTER=Counter@api
binds theCOUNTER
Durable Object namespace using theCounter
class exported by the mountedapi
worker. - Update error message when attempting to access bindings via global in modules mode for Cloudflare Pages
- When the
fetch_refuses_unknown_protocols
compatibility flag isn't set, log a warning when attempting to use a protocol other thanhttp
orhttps
- The upstream URL is now validated on startup if specified
Fixes
- Copy
webSocket
when constructing aResponse
from an existingResponse
, closes issue #100, thanks @universse - Allow constructing
null
body with empty-string, closes issue #101, thanks @PH4NTOMiki - Remove ASCII whitespace from
atob
input, closes issue #104, thanks @dan-lee - Remove keys limit from Durable Objects
list()
method, closes issue #105, thanks @vzaramel - Allow
Sec-WebSocket-Protocol
header in WebSocketfetch
, closes issue #106, thanks @f5io - Fix uncaught rejection when closing server-sent events connection, closes issue #107, thanks @dan-lee
- Bump
undici
to4.11.1
, allowingResponse
s withnull
bodies to be cloned, closes issue #110, thanks @payellodevsupport - Allow forbidden header mutation on
Request
/Response
instances, closes cloudflare/wrangler2 issue #59, thanks @oliverjam - Allow missing parent script with mounted workers
- Correctly handle attempting to read a key in a namespace that is also a key when using
FileStorage
, and throw when trying to write in this case (this is a limitation of Miniflare's file-system storage). - When the
fetch_refuses_unknown_protocols
compatibility flag isn't set, correctly replace non-standard protocols (e.g.random://
) withhttp://
infetch
. - Remove types dependency on
lib.webworker
- Incoming
https
requests will now havehttps
URLs