如何從node.js獲取IP地址我嘗試了很多方法,但它不起作用並返回:: ffff:127.0.0.1請給我一些建議如何獲取node.js中的IP地址
這是我的代碼:
app.put('/update-user-info', function(req, res){
// it's doesn't work and return ::ffff:127.0.0.1
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress;
});
使用'req.ip'。如果你在一個proxi後面看看:http://expressjs.com/en/guide/behind-proxies.html –