Comments (11)
What kind of error occured?
from express-ip.
Fixed
from express-ip.
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);
});
from express-ip.
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!
from express-ip.
Hmmnn. I will add support for that. Thanks raising this up
from express-ip.
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!
from express-ip.
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();
});
from express-ip.
@mikestecker I think there's an issue with the ngrok header response. I came across that back ago.
from express-ip.
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!
from express-ip.
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'
}
from express-ip.
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();
};
from express-ip.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from express-ip.