admin08077 commited on
Commit
465920d
·
verified ·
1 Parent(s): 07060d4

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +5 -4
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: Redirect all non-API requests to index.html
218
- // In Express 5, wildcard parameters must be named.
219
- // Using '/:path*' satisfies path-to-regexp v8 requirements for catch-all routing.
220
- app.get('/:path*', (req, res) => {
 
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
  }