跳转到内容
搜索文档

实时重载

最后更新 查看 MarkdownAgent 设置

liveReload 设置为 true 时,Miniflare 会在 Worker 脚本 变更时自动刷新浏览器。

const mf = new Miniflare({
	liveReload: true,
});

Miniflare 只会在 Content-Type 标头设置为 text/html 的 响应末尾注入实时重载所需的 <script> 标签:

export default {
	fetch() {
		const body = `
      <!DOCTYPE html>
      <html>
      <body>
        <p>Try update me!</p>
      </body>
      </html>
    `;

		return new Response(body, {
			headers: { "Content-Type": "text/html; charset=utf-8" },
		});
	},
};

这篇文档对您有帮助吗?