Skip to content

Commit

Permalink
fix: fix mismatch Response class
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 18, 2023
1 parent 2e39a2a commit 65258b0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/vite-node-miniflare/src/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,19 @@ export function vitePluginViteNodeMiniflare(pluginOptions: {
await miniflare.ready;
}

// workaround typing mismatch between "lib.dom" and "miniflare"
// workaround Request/Response polyfills mismatch and typings mismatch between "lib.dom" and "miniflare"
const request = h3.toWebRequest(event) as any as MiniflareRequest;
return miniflare.dispatchFetch(request.url, {
const res = await miniflare.dispatchFetch(request.url, {
method: request.method,
headers: request.headers,
body: request.body,
duplex: "half",
}) as any as Response;
});
return new Response(res.body as any, {
status: res.status,
statusText: res.statusText,
headers: res.headers,
});
});

const app = h3.createApp().use([
Expand Down

0 comments on commit 65258b0

Please sign in to comment.