Use x-forwarded-for header to get ip. fallback fo clientIP
This commit is contained in:
parent
ea43a9e371
commit
deb078980b
3
app.js
3
app.js
@ -8,7 +8,8 @@ const instanceNumber = Math.floor(Math.random() * 101);
|
||||
const app = express();
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.send(`node-test instance ${instanceNumber}, your IP: ${req.ip}`);
|
||||
var ip = req.headers['x-forwarded-for'] || req.ip;
|
||||
res.send(`node-test instance ${instanceNumber}, your IP: ${ip}`);
|
||||
});
|
||||
|
||||
app.listen(PORT, HOST, () => {
|
||||
|
Loading…
Reference in New Issue
Block a user