const express = require('express');
const path = require('path');
const app = express();
const PORT = 5000;
// 静态文件服务
app.use(express.static(path.join(__dirname, '../frontend/dist')));
// 健康检查
app.get('/api/health', (req, res) => {
res.json({
success: true,
message: '端口5000测试服务',
version: '1.0.0',
timestamp: new Date().toISOString(),
bind_address: '0.0.0.0',
port: PORT,
status: 'running'
});
});
// 测试页面
app.get('/test-5000', (req, res) => {
res.send(`
端口5000测试
✅ 端口5000测试成功!
服务器: 43.161.248.209:${PORT}
绑定地址: 0.0.0.0
状态: 运行正常
`);
});
// 默认路由
app.get('/', (req, res) => {
res.redirect('/test-5000');
});
// 启动服务器 - 明确绑定到0.0.0.0
const server = app.listen(PORT, '0.0.0.0', () => {
const address = server.address();
console.log(`
🔧 端口5000测试服务器
=============================
📍 绑定地址: ${address.address}:${address.port}
🌐 外部访问: http://43.161.248.209:${PORT}
🔗 测试页面: http://43.161.248.209:${PORT}/test-5000
✅ 明确绑定到: 0.0.0.0
=============================
`);
});
// 错误处理
server.on('error', (err) => {
console.error('服务器启动错误:', err);
});