serve from file instead of object

This commit is contained in:
eko 2025-12-02 16:13:28 +07:00
parent ea72b74447
commit 998d8b3b31
1 changed files with 2 additions and 0 deletions

View File

@ -194,6 +194,7 @@ export const createServer = async () => {
if (core[pathname]) content = core[pathname];
else if (site[pathname]) content = site[pathname];
else if (pub[pathname]) {
console.log(`[DEBUG] Serving file from public folder: ${pathname}`);
// Serve file directly from public folder
const filePath = dir(`public/${pathname}`);
const file = Bun.file(filePath);
@ -230,6 +231,7 @@ export const createServer = async () => {
}
}
console.log(`[DEBUG] Serving file: ${pathname} with content type: ${opt?.headers?.get("Content-Type") || "unknown"}`);
// Return the file directly (Bun will stream it efficiently)
return new Response(file, {
status: 200,