Skip to content

Commit

Permalink
always respond with buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
leoortizz committed Jun 18, 2024
1 parent 9d1e9eb commit dd8097e
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions packages/firebase-frameworks/src/sveltekit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,11 @@ export const handle = async (req: Request, res: Response) => {
return res.writeHead(404, "Not Found").end();
}

let body;
const contentType = rendered.headers.get("Content-Type");
if (
contentType.startsWith("text/") ||
contentType.startsWith("application/json") ||
contentType.startsWith("application/xml") ||
contentType.startsWith("application/javascript") ||
contentType.startsWith("application/vnd.ms-excel")
) {
body = await rendered.text();
} else {
body = Buffer.from(await rendered.arrayBuffer());
}
const body = (await rendered.arrayBuffer()) as ArrayBuffer;

return res.writeHead(rendered.status, Object.fromEntries(rendered.headers)).end(body);
return res
.writeHead(rendered.status, Object.fromEntries(rendered.headers))
.end(Buffer.from(body));
};

// https://github.com/jthegedus/svelte-adapter-firebase/blob/main/src/files/firebase-to-svelte-kit.js
Expand Down

0 comments on commit dd8097e

Please sign in to comment.