kinaiok commited on
Commit
38d5d2a
·
1 Parent(s): 213762e

fix: simplify SPA fallback to not interfere with API routes

Browse files
Files changed (1) hide show
  1. artifacts/api-server/src/app.ts +3 -7
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 - 非 API 路由都返回 index.html
54
- app.use((req, res, next) => {
55
- if (!req.path.startsWith("/api") && !req.path.startsWith("/v1")) {
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;