kinaiok commited on
Commit Β·
f5dc292
1
Parent(s): 62c2e34
Fix API routing - prevent SPA fallback from catching API requests
Browse files
artifacts/api-server/src/app.ts
CHANGED
|
@@ -50,8 +50,13 @@ 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 |
res.sendFile(path.join(frontendDistPath, "index.html"));
|
| 56 |
});
|
| 57 |
|
|
|
|
| 50 |
const frontendDistPath = path.join(__dirname, "../../image-gen/dist/public");
|
| 51 |
app.use(express.static(frontendDistPath));
|
| 52 |
|
| 53 |
+
// SPA fallback - εͺθηι API θ«ζ±
|
| 54 |
+
app.use((req, res, next) => {
|
| 55 |
+
// ε¦ζζ― API θ«ζ±δ½ζ²ζθ’«θηοΌθΏε 404
|
| 56 |
+
if (req.path.startsWith('/api') || req.path.startsWith('/v1')) {
|
| 57 |
+
return res.status(404).json({ error: 'API endpoint not found' });
|
| 58 |
+
}
|
| 59 |
+
// ε
Άδ»θ«ζ±θΏε SPA η index.html
|
| 60 |
res.sendFile(path.join(frontendDistPath, "index.html"));
|
| 61 |
});
|
| 62 |
|