CatPtain commited on
Commit
e457032
·
verified ·
1 Parent(s): b7c3405

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +8 -10
server.js CHANGED
@@ -19,7 +19,7 @@ const { URL } = require('url'); // 用于验证 URL 格式
19
  const app = express();
20
 
21
  // === 配置常量 ===
22
- const PORT = process.env.PORT; // 动态分配的端口
23
  const HOST = '0.0.0.0';
24
 
25
  // 检查 PORT 是否有效
@@ -68,18 +68,15 @@ setInterval(() => {
68
  }, CLEANUP_INTERVAL);
69
 
70
  // 健康检查路由
71
- app.get("/", (req, res) => {
72
  res.status(200).json({
73
- message: "Server is healthy and running!",
74
- host: HOST,
75
- port: PORT, // 当前监听的端口
76
- env: {
77
- PORT: process.env.PORT,
78
- NODE_ENV: process.env.NODE_ENV,
79
- },
80
  });
81
  });
82
 
 
83
  // === 路由与业务逻辑 ===
84
 
85
  // 存储 URL(POST 请求)
@@ -141,4 +138,5 @@ app.listen(PORT, HOST, (err) => {
141
  });
142
 
143
  // 打印环境变量(调试使用)
144
- console.log("Environment Variables:", process.env);
 
 
19
  const app = express();
20
 
21
  // === 配置常量 ===
22
+ const PORT = process.env.PORT || 7860; // 动态分配的端口
23
  const HOST = '0.0.0.0';
24
 
25
  // 检查 PORT 是否有效
 
68
  }, CLEANUP_INTERVAL);
69
 
70
  // 健康检查路由
71
+ app.get('/', (req, res) => {
72
  res.status(200).json({
73
+ message: "Server is running with backup port.",
74
+ port: PORT || "undefined",
75
+ environment: process.env,
 
 
 
 
76
  });
77
  });
78
 
79
+
80
  // === 路由与业务逻辑 ===
81
 
82
  // 存储 URL(POST 请求)
 
138
  });
139
 
140
  // 打印环境变量(调试使用)
141
+ console.log("Full Environment Variables:", process.env);
142
+