mirror of
https://github.com/samanhappy/mcphub.git
synced 2026-01-03 13:18:59 -05:00
fix: add catch-all route to serve frontend index.html in AppServer in… (#24)
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { check } from 'express-validator';
|
import { check } from 'express-validator';
|
||||||
import path from 'path';
|
|
||||||
import {
|
import {
|
||||||
getAllServers,
|
getAllServers,
|
||||||
getAllSettings,
|
getAllSettings,
|
||||||
@@ -72,10 +71,6 @@ export const initRoutes = (app: express.Application): void => {
|
|||||||
], changePassword);
|
], changePassword);
|
||||||
|
|
||||||
app.use('/api', router);
|
app.use('/api', router);
|
||||||
|
|
||||||
app.get('*', (_req, res) => {
|
|
||||||
res.sendFile(path.join(process.cwd(), 'frontend', 'dist', 'index.html'));
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import config from './config/index.js';
|
import config from './config/index.js';
|
||||||
|
import path from 'path';
|
||||||
import { initMcpServer } from './services/mcpService.js';
|
import { initMcpServer } from './services/mcpService.js';
|
||||||
import { initMiddlewares } from './middlewares/index.js';
|
import { initMiddlewares } from './middlewares/index.js';
|
||||||
import { initRoutes } from './routes/index.js';
|
import { initRoutes } from './routes/index.js';
|
||||||
@@ -37,6 +38,11 @@ export class AppServer {
|
|||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error initializing MCP server:', error);
|
console.error('Error initializing MCP server:', error);
|
||||||
throw error;
|
throw error;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.app.get('*', (_req, res) => {
|
||||||
|
res.sendFile(path.join(process.cwd(), 'frontend', 'dist', 'index.html'));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error initializing server:', error);
|
console.error('Error initializing server:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user