const express = require('express'); const path = require('path'); const app = express(); const PORT = 5000; // 静态文件服务 - 前端 app.use('/app', express.static(path.join(__dirname, '../frontend/dist'))); // API路由 app.get('/api/health', (req, res) => { res.json({ status: 'healthy', service: 'company-finance-system', timestamp: new Date().toISOString(), version: '1.0.0', endpoints: { frontend: '/app/index.html', api: '/api/*', test: '/test' } }); }); // 测试页面 app.get('/test', (req, res) => { res.send(`
服务器: 43.161.248.209:5000
`); }); // 默认路由重定向到前端 app.get('/', (req, res) => { res.redirect('/app/index.html'); }); // 404处理 app.use((req, res) => { res.status(404).send('页面未找到 - 请访问 前端应用'); }); app.listen(PORT, '0.0.0.0', () => { console.log(`🚀 统一服务器运行在: http://0.0.0.0:${PORT}`); console.log(`🌐 前端应用: http://0.0.0.0:${PORT}/app/index.html`); console.log(`🔧 测试页面: http://0.0.0.0:${PORT}/test`); });