feat: serve static assets from frontend build directory

This commit is contained in:
2025-06-04 11:19:57 +09:00
parent 020505b821
commit 68f762ffb0

View File

@ -62,11 +62,16 @@ app.post("/api/episodes/:id/regenerate", (c) => {
// 静的ファイルの処理
// Vite ビルドの静的ファイルmain.js, assets/ など)
app.get("/main.js", async (c) => {
const filePath = path.join(frontendBuildDir, "main.js");
app.get("/assets/*", async (c) => {
const filePath = path.join(frontendBuildDir, c.req.path);
const file = Bun.file(filePath);
if (await file.exists()) {
return c.body(file, 200, { "Content-Type": "application/javascript; charset=utf-8" });
const contentType = filePath.endsWith(".js")
? "application/javascript"
: filePath.endsWith(".css")
? "text/css"
: "application/octet-stream";
return c.body(file, 200, { "Content-Type": contentType });
}
return c.notFound();
});