fix: add catch-all route to serve frontend index.html in AppServer in… (#24)

This commit is contained in:
samanhappy
2025-04-18 22:44:12 +08:00
committed by GitHub
parent 6a5039a90e
commit c4008f617d
2 changed files with 6 additions and 5 deletions

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