express-ip
express-ip copied to clipboard
error: 'Error occured while trying to process the information'
error: 'Error occured while trying to process the information' - how can I debug this?
What kind of error occured?
Fixed
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); });
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!
Hmmnn. I will add support for that. Thanks raising this up
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!
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 I think there's an issue with the ngrok header response. I came across that back ago.
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!
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'
}
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();
};