fix: correct static file serving and entry point
This commit is contained in:
@ -8,6 +8,6 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<script type="module" src="/src/main.tsx" defer></script>
|
<script type="module" src="/main.js" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
18
server.ts
18
server.ts
@ -20,7 +20,7 @@ db.exec(fs.readFileSync(path.join(projectRoot, "schema.sql"), "utf-8"));
|
|||||||
|
|
||||||
// 静的ファイルパスの設定
|
// 静的ファイルパスの設定
|
||||||
const frontendPublicDir = path.join(projectRoot, "frontend", "public");
|
const frontendPublicDir = path.join(projectRoot, "frontend", "public");
|
||||||
const frontendBuildDir = path.join(projectRoot, "dist");
|
const frontendBuildDir = path.join(projectRoot, "frontend", "dist");
|
||||||
const podcastAudioDir = path.join(projectRoot, "static", "podcast_audio");
|
const podcastAudioDir = path.join(projectRoot, "static", "podcast_audio");
|
||||||
const generalPublicDir = path.join(projectRoot, "public");
|
const generalPublicDir = path.join(projectRoot, "public");
|
||||||
|
|
||||||
@ -61,20 +61,12 @@ app.post("/api/episodes/:id/regenerate", (c) => {
|
|||||||
|
|
||||||
// 静的ファイルの処理
|
// 静的ファイルの処理
|
||||||
|
|
||||||
// Next.jsのビルドファイル
|
// Vite ビルドの静的ファイル(main.js, assets/ など)
|
||||||
app.get("/_next/*", async (c) => {
|
app.get("/main.js", async (c) => {
|
||||||
const assetPath = c.req.path.substring("/_next/".length);
|
const filePath = path.join(frontendBuildDir, "main.js");
|
||||||
const filePath = path.join(frontendBuildDir, "_next", assetPath);
|
|
||||||
const file = Bun.file(filePath);
|
const file = Bun.file(filePath);
|
||||||
if (await file.exists()) {
|
if (await file.exists()) {
|
||||||
let contentType = "application/octet-stream";
|
return c.body(file, 200, { "Content-Type": "application/javascript; charset=utf-8" });
|
||||||
if (filePath.endsWith(".js"))
|
|
||||||
contentType = "application/javascript; charset=utf-8";
|
|
||||||
else if (filePath.endsWith(".css")) contentType = "text/css; charset=utf-8";
|
|
||||||
else if (filePath.endsWith(".png")) contentType = "image/png";
|
|
||||||
else if (filePath.endsWith(".jpg") || filePath.endsWith(".jpeg"))
|
|
||||||
contentType = "image/jpeg";
|
|
||||||
return c.body(file, 200, { "Content-Type": contentType });
|
|
||||||
}
|
}
|
||||||
return c.notFound();
|
return c.notFound();
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user