diff --git a/src/routes/index.ts b/src/routes/index.ts index 45e82cc..ade6197 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -1,6 +1,5 @@ import express from 'express'; import { check } from 'express-validator'; -import path from 'path'; import { getAllServers, getAllSettings, @@ -72,10 +71,6 @@ export const initRoutes = (app: express.Application): void => { ], changePassword); app.use('/api', router); - - app.get('*', (_req, res) => { - res.sendFile(path.join(process.cwd(), 'frontend', 'dist', 'index.html')); - }); }; export default router; diff --git a/src/server.ts b/src/server.ts index fcbe6c9..57a9739 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,5 +1,6 @@ import express from 'express'; import config from './config/index.js'; +import path from 'path'; import { initMcpServer } from './services/mcpService.js'; import { initMiddlewares } from './middlewares/index.js'; import { initRoutes } from './routes/index.js'; @@ -37,6 +38,11 @@ export class AppServer { .catch((error) => { console.error('Error initializing MCP server:', error); throw error; + }) + .finally(() => { + this.app.get('*', (_req, res) => { + res.sendFile(path.join(process.cwd(), 'frontend', 'dist', 'index.html')); + }); }); } catch (error) { console.error('Error initializing server:', error);