xxxxxxxxxx
const IP = req.headers['x-forwarded-for'] || req.socket.remoteAddress;
// DEPRECATED: req.connection.remoteAddress;
xxxxxxxxxx
const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
xxxxxxxxxx
const express = require('express');
const app = express();
app.get('/',function(req, res) {
const ipAddress = req.socket.remoteAddress;
res.send(ipAddress);
});
xxxxxxxxxx
const express = require('express');
const app = express();
app.get('/',function(req, res) {
const ipAddress = req.socket.remoteAddress;
res.send(ipAddress);
});
app.listen(3000, () => console.log(`Server is listening on port 3000`))
xxxxxxxxxx
var ip = req.headers['x-forwarded-for'] || req.socket.remoteAddress