Compare commits

...

1 Commits

Author SHA1 Message Date
samanhappy
c4008f617d fix: add catch-all route to serve frontend index.html in AppServer in… (#24) 2025-04-18 22:44:12 +08:00
2 changed files with 6 additions and 5 deletions

View File

@@ -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;

View File

@@ -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);