76 lines
2.8 KiB
JavaScript
76 lines
2.8 KiB
JavaScript
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(`
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head><title>系统测试</title><meta charset="utf-8"></head>
|
|
<body style="font-family: Arial; margin: 40px;">
|
|
<h1>✅ 公司财务管理系统 - 统一访问入口</h1>
|
|
<p>服务器: 43.161.248.209:5000</p>
|
|
|
|
<div style="margin: 20px 0; padding: 20px; border: 2px solid #4CAF50; border-radius: 10px;">
|
|
<h2>🚀 立即访问:</h2>
|
|
<p><a href="/app/index.html" style="font-size: 18px; color: #1890ff; text-decoration: none;">👉 点击这里打开前端应用</a></p>
|
|
<p>或复制链接:<code>http://43.161.248.209:5000/app/index.html</code></p>
|
|
</div>
|
|
|
|
<div style="margin: 20px 0;">
|
|
<h3>🔗 其他链接:</h3>
|
|
<ul>
|
|
<li><a href="/api/health">API健康检查</a></li>
|
|
<li><a href="/api/customers">客户API测试</a></li>
|
|
<li><a href="http://43.161.248.209:5001/test">详细测试页面</a> (端口5001)</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div style="background: #f5f5f5; padding: 15px; border-radius: 5px;">
|
|
<h3>📱 测试说明:</h3>
|
|
<p>1. 此页面通过<strong>端口5000</strong>访问(已确认开放)</p>
|
|
<p>2. 前端应用已集成到同一端口</p>
|
|
<p>3. 无需担心8080端口问题</p>
|
|
<p>4. 请现在测试:<a href="/app/index.html">/app/index.html</a></p>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
`);
|
|
});
|
|
|
|
// 默认路由重定向到前端
|
|
app.get('/', (req, res) => {
|
|
res.redirect('/app/index.html');
|
|
});
|
|
|
|
// 404处理
|
|
app.use((req, res) => {
|
|
res.status(404).send('页面未找到 - 请访问 <a href="/app/index.html">前端应用</a>');
|
|
});
|
|
|
|
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`);
|
|
});
|