mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
38 lines
887 B
JavaScript
38 lines
887 B
JavaScript
import express from 'express';
|
|
import cors from 'cors';
|
|
import { useUserRoute } from './service/route/user.js';
|
|
import { useAppRoute } from './service/route/app.js';
|
|
import { useKbRoute } from './service/route/kb.js';
|
|
import { useSystemRoute } from './service/route/system.js';
|
|
|
|
const app = express();
|
|
app.use(cors());
|
|
app.use(express.json());
|
|
app.use(express.static('dist'));
|
|
|
|
useUserRoute(app);
|
|
useAppRoute(app);
|
|
useKbRoute(app);
|
|
useSystemRoute(app);
|
|
|
|
app.get('/*', (req, res) => {
|
|
try {
|
|
res.sendFile(new URL('dist/index.html', import.meta.url).pathname);
|
|
} catch (error) {
|
|
res.end();
|
|
}
|
|
});
|
|
|
|
app.use((err, req, res, next) => {
|
|
try {
|
|
res.sendFile(new URL('dist/index.html', import.meta.url).pathname);
|
|
} catch (error) {
|
|
res.end();
|
|
}
|
|
});
|
|
|
|
const PORT = process.env.PORT || 3001;
|
|
app.listen(PORT, () => {
|
|
console.log(`Server is running on port ${PORT}`);
|
|
});
|