I've been trying for a while to get the ip address of the client (me) using Koajs; however, I keep getting the local host address of ::1
I tried using this.request.ip and this.request.headers['x-forwarded-for'] with app.proxy set to true, still I get the arbitrary local host ip.
I do need the IP address for the geolocation app that I'm building.
Here's my code:
var koa = require('koa');
var app = koa();
app.proxy = true;
app.use(function *(){
this.body = this.request.ip; // also tried request.headers['x-forwarded-for'];
});
app.listen(3000);