完善博客评论功能

This commit is contained in:
2024-08-31 13:38:22 +08:00
parent 29f2c09a69
commit 8ea3a7b25c
5 changed files with 110 additions and 16 deletions

View File

@@ -0,0 +1,11 @@
import { Request, Response, NextFunction } from "express"
import Logger from "../Logger";
const logger = new Logger('MountIP')
let MountIP = (req: Request, res: Response, next: NextFunction) => {
req.body._ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress || req.ip;
logger.info(`[${req.method}][${req.url.split('?')[0]}] IP解析成功${req.body._ip}`);
next();
}
export default MountIP;