const server = Bun.serve({ port: Number(process.env.PORT || 3000), async fetch(req) { const url = new URL(req.url); let pathname = url.pathname; if (pathname === "/") pathname = "/index.html"; // Prevent path traversal pathname = pathname.replace(/\.\.+/g, ""); const filePath = `.${pathname}`; const file = Bun.file(filePath); if (await file.exists()) { return new Response(file); } return new Response("Not found", { status: 404 }); }, }); console.log(`Server running at http://localhost:${server.port}`);