Files
tonePage/Server/src/Plugs/Middleware/MountIP.ts
2024-08-31 13:38:22 +08:00

11 lines
423 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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;