const express = require('express'); const path = require('path'); const app = express(); const PORT = 3000; // 使用已验证可访问的端口 // 中间件 app.use(express.json()); app.use(express.urlencoded({ extended: true })); // 静态文件服务 - 前端应用 app.use('/app', express.static(path.join(__dirname, '../frontend/dist'))); // 健康检查 app.get('/health', (req, res) => { res.json({ status: 'healthy', service: 'company-finance-system', timestamp: new Date().toISOString(), version: '1.0.0', port: PORT, endpoints: { frontend: '/app/index.html', test: '/test', api: '/api/health' } }); }); app.get('/api/health', (req, res) => { res.json({ status: 'healthy', message: 'API服务正常', timestamp: new Date().toISOString() }); }); // 测试页面 app.get('/test', (req, res) => { res.send(` ✅ 系统测试 - 端口${PORT}

🏢 公司财务管理系统 - 生产环境

服务器: 43.161.248.209:${PORT}

状态: ✅ 运行正常

🎉 恭喜!系统部署成功

所有服务已就绪,可以开始使用。

🚀 立即开始:

进入系统 健康检查

📊 系统信息:

📱 测试说明:

1. 此页面通过端口${PORT}访问(已确认开放)

2. 前端应用已集成到同一端口

3. 所有功能均可正常使用

4. 请现在测试:/app/index.html

`); }); // 默认路由重定向到前端 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} 🌐 外部访问: http://43.161.248.209:${PORT} 🔗 重要链接: - 前端应用: http://43.161.248.209:${PORT}/app/index.html - 测试页面: http://43.161.248.209:${PORT}/test - 健康检查: http://43.161.248.209:${PORT}/health ✅ 端口${PORT}已验证可访问 ✅ 所有服务已集成 ✅ 等待用户测试 ⏰ 部署时间: ${new Date().toISOString()} ==================================== `); });