|
@@ -61,7 +61,8 @@ app.use(bodyParser.urlencoded({
|
|
|
// 自定义日志中间件
|
|
// 自定义日志中间件
|
|
|
app.use((req, res, next) => {
|
|
app.use((req, res, next) => {
|
|
|
const now = new Date().toISOString();
|
|
const now = new Date().toISOString();
|
|
|
- console.log(`[${now}] ${req.method} ${req.url}`);
|
|
|
|
|
|
|
+ const ip = req.headers['x-forwarded-for'] || req.ip;
|
|
|
|
|
+ console.log(`[${now}] ${ip} ${req.method} ${req.url}`);
|
|
|
next(); // 调用 next() 函数,将请求传递给下一个中间件或路由处理程序
|
|
next(); // 调用 next() 函数,将请求传递给下一个中间件或路由处理程序
|
|
|
});
|
|
});
|
|
|
|
|
|