This commit is contained in:
Rizky 2024-07-05 10:21:42 +07:00
parent beeb013b28
commit 8aedfdf82f
1 changed files with 11 additions and 9 deletions

View File

@ -353,15 +353,17 @@ export const _ = {
if (req.headers.get("accept-encoding")?.includes("gzip")) {
const file = Bun.file(src_path);
return new Response(
await gzipAsync(new Uint8Array(await file.arrayBuffer())),
{
headers: {
"content-encoding": "gzip",
"content-type": mime.getType(src_path) || "",
},
}
);
if (await file.exists()) {
return new Response(
await gzipAsync(new Uint8Array(await file.arrayBuffer())),
{
headers: {
"content-encoding": "gzip",
"content-type": mime.getType(src_path) || "",
},
}
);
}
}
return index_html;