Spaces:
Running
Running
Update server.js
Browse files
server.js
CHANGED
|
@@ -214,10 +214,11 @@ app.get(`${CITI_BASE}/accounts/:accountId/transactions`, (req, res) => {
|
|
| 214 |
// Serve frontend files from the dist directory
|
| 215 |
app.use(express.static(path.join(__dirname, 'dist')));
|
| 216 |
|
| 217 |
-
// SPA Fallback:
|
| 218 |
-
// In Express 5,
|
| 219 |
-
//
|
| 220 |
-
app.
|
|
|
|
| 221 |
if (req.path.startsWith('/api')) {
|
| 222 |
return res.status(404).json({ error: 'API endpoint not found' });
|
| 223 |
}
|
|
|
|
| 214 |
// Serve frontend files from the dist directory
|
| 215 |
app.use(express.static(path.join(__dirname, 'dist')));
|
| 216 |
|
| 217 |
+
// SPA Fallback: Catch any request that didn't match an API route or a static file.
|
| 218 |
+
// In Express 5, using a middleware function without a path is the safest way
|
| 219 |
+
// to implement a catch-all fallback for Single Page Applications.
|
| 220 |
+
app.use((req, res) => {
|
| 221 |
+
// Safeguard: Do not serve index.html for missing API routes
|
| 222 |
if (req.path.startsWith('/api')) {
|
| 223 |
return res.status(404).json({ error: 'API endpoint not found' });
|
| 224 |
}
|