express-ip icon indicating copy to clipboard operation
express-ip copied to clipboard

error: 'Error occured while trying to process the information'

Open LukeXF opened this issue 7 years ago • 11 comments

error: 'Error occured while trying to process the information' - how can I debug this?

LukeXF avatar Dec 04 '18 11:12 LukeXF

What kind of error occured?

CITGuru avatar Dec 05 '18 06:12 CITGuru

Fixed

CITGuru avatar Dec 05 '18 06:12 CITGuru

Hi guys! I'm getting that error as well, how did you fix it? Thanks!

just doing this (relevant stuff):

const expressip = require('express-ip'); app.use(expressip().getIpInfoMiddleware); // GEO

app.get('/geo-test', function (req, res) { res.send(req.ipInfo); });

fcolella avatar Jan 10 '19 17:01 fcolella

Nevermind, I have the latest version (1.0.3) but it doesn't have this code:

if ((ip === '127.0.0.1' || ip === '::1')) { return {error:"This won't work on localhost"} }

it has this:

if ((ip === '127.0.0.1')) { return {error:"This won't work on localhost"} }

And my localhost was returning ::1 Also not working when IP data comes with multiple IPs like so "200.x.x.x, 10.x.x.x, 10.x.x.x" Maybe reverse proxy issue? Thanks!

fcolella avatar Jan 10 '19 18:01 fcolella

Hmmnn. I will add support for that. Thanks raising this up

CITGuru avatar Jan 10 '19 19:01 CITGuru

is it solve? I'm also facing the same thing

Nevermind, I have the latest version (1.0.3) but it doesn't have this code:

if ((ip === '127.0.0.1' || ip === '::1')) { return {error:"This won't work on localhost"} }

it has this:

if ((ip === '127.0.0.1')) { return {error:"This won't work on localhost"} }

And my localhost was returning ::1 Also not working when IP data comes with multiple IPs like so "200.x.x.x, 10.x.x.x, 10.x.x.x" Maybe reverse proxy issue? Thanks!

muhaimincs avatar Apr 23 '19 07:04 muhaimincs

I'm having this issue also. I've tried testing using ngrok and console.log my info, but only receive { error: 'Error occured while trying to process the information' }

my code is simply as follows:

server.express.use(expressip().getIpInfoMiddleware);
server.express.use((req, res, next) => {
  const userIp = req.ipInfo;
  if (userIp) {
    console.log(userIp);
    req.userIp = userIp;
  }
  next();
});

mikestecker avatar Aug 22 '19 23:08 mikestecker

@mikestecker I think there's an issue with the ngrok header response. I came across that back ago.

CITGuru avatar Aug 27 '19 09:08 CITGuru

Hello everyone, I have a similar issue. This is the code - app.get("/ipInfo", function(req,res){ var myEnv = req.connection.remoteAddress; if (myEnv == "::ffff:127.0.0.1") { res.send("does this work? " + req.ipInfo); } else { res.send(req.ipInfo); }

});

It works on local and says - This cannot work on a localhost. It works on NGROK and returns the ipInfo object with all the information

However, on a live server (heroku) It says {"error":"Error occured while trying to process the information"}

please assist me,

Thanks!

tamirDavidoff avatar Apr 12 '20 14:04 tamirDavidoff

express-ip doesn't seem to like x-forwarded-ip headers:

Reproducing the steps: Using Nginx + NodeJS + Cloudflare.

Example:

{
  ip: '1.3.3.7,1.1.1.1',
  error: 'Error occured while trying to process the information'
}

2M4U avatar Oct 09 '20 17:10 2M4U

Here is a solution for the issue when we have a proxy

  const getIpInfoMiddleware = function(req, res, next) {
    const xForwardedFor = (req.headers["x-forwarded-for"] || "").
        replace(/:\d+$/, "");
    let ip = xForwardedFor || req.connection.remoteAddress;
    ip = ip.split(",")[0];  //this line select the first ip (if severals)
    req.ipInfo = {ip, ...getIpInfo(ip)};
    next();
  };

seba-wetzel avatar Feb 13 '21 17:02 seba-wetzel