kinaiok commited on
Commit ·
38d5d2a
1
Parent(s): 213762e
fix: simplify SPA fallback to not interfere with API routes
Browse files
artifacts/api-server/src/app.ts
CHANGED
|
@@ -50,13 +50,9 @@ app.use("/api/v1", openaiRouter);
|
|
| 50 |
const frontendDistPath = path.join(__dirname, "../../image-gen/dist/public");
|
| 51 |
app.use(express.static(frontendDistPath));
|
| 52 |
|
| 53 |
-
// SPA fallback -
|
| 54 |
-
app.use((req, res
|
| 55 |
-
|
| 56 |
-
res.sendFile(path.join(frontendDistPath, "index.html"));
|
| 57 |
-
} else {
|
| 58 |
-
next();
|
| 59 |
-
}
|
| 60 |
});
|
| 61 |
|
| 62 |
export default app;
|
|
|
|
| 50 |
const frontendDistPath = path.join(__dirname, "../../image-gen/dist/public");
|
| 51 |
app.use(express.static(frontendDistPath));
|
| 52 |
|
| 53 |
+
// SPA fallback - 只在沒有找到靜態檔案時返回 index.html
|
| 54 |
+
app.use((req, res) => {
|
| 55 |
+
res.sendFile(path.join(frontendDistPath, "index.html"));
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
});
|
| 57 |
|
| 58 |
export default app;
|