Skip to content

Commit 1656118

Browse files
zhoushaw[TMates]
andcommitted
fix(treeshake-server): fix Buffer to BodyInit assignment error in Response
Co-Authored-By: [TMates] <tmates@bytedance.com>
1 parent 459c21e commit 1656118

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/treeshake-server/src/frontend/embeddedAdapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function createEmbeddedFrontendAdapter(
6969
const stat = await fs.promises.stat(filePath);
7070
if (stat.isFile()) {
7171
const buf = await fs.promises.readFile(filePath);
72-
return new Response(buf, {
72+
return new Response(new Uint8Array(buf), {
7373
status: 200,
7474
headers: { 'Content-Type': contentTypeByExt(filePath) },
7575
});
@@ -89,7 +89,7 @@ export function createEmbeddedFrontendAdapter(
8989
}
9090
try {
9191
const buf = await fs.promises.readFile(fallbackPath);
92-
return new Response(buf, {
92+
return new Response(new Uint8Array(buf), {
9393
status: 200,
9494
headers: { 'Content-Type': contentTypeByExt(fallbackPath) },
9595
});

packages/treeshake-server/src/http/routes/static.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async function serveLocalFile(c: any, rootDir: string) {
2828
}
2929
try {
3030
const buf = await fs.promises.readFile(filePath);
31-
return new Response(buf, {
31+
return new Response(new Uint8Array(buf), {
3232
status: 200,
3333
headers: { 'Content-Type': contentTypeByExt(filePath) },
3434
});

0 commit comments

Comments
 (0)