当前位置 : 主页 > 编程语言 > java >

node 获取客户端ip

来源:互联网 收集:自由互联 发布时间:2022-10-15
npm install request-ipconst requestIp = require('request-ip'); // inside middleware handler const ipMiddleware = function(req, res, next) { const clientIp = requestIp.getClientIp(req); next(); }; // on localhost you'll see 127.0.0.1 if you'


npm install request-ipconst requestIp = require('request-ip');

// inside middleware handler
const ipMiddleware = function(req, res, next) {
const clientIp = requestIp.getClientIp(req);
next();
};

// on localhost you'll see 127.0.0.1 if you're using IPv4
// or ::1, ::ffff:127.0.0.1 if you're using IPv6


上一篇:linus 禁止root登录
下一篇:没有了
网友评论