You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
varhttp=require('http')varexpress=require('express')varapp=express()app.enable('trust proxy')varraven=require('raven')vardsn='';raven.config(dsn,{autoBreadcrumbs: true}).install();app.use(raven.requestHandler());app.get('/',function(req,res){res.send('hello world '+req.ip)})app.get('/err',function(req,res){thrownewError('test')})app.use(raven.errorHandler());http.createServer(app).listen(8888);
Set up a proxy to forward to the node app, I used nginx with the following config:
Visit / via the proxy and you'll see hello world and the IP printed
Visit /err via the proxy, it'll throw an error, check this in sentry it won't show the IP. I checked that the line mentioned above is resulting in req.ip undefined.
I've not had time to debug why req.ip is undefined but since it's not undefined when accessed outside raven I'm assuming it's a bug in raven.
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
When
app.enable('trust proxy')is enabledreq.ipisundefinedhere https://github.com/getsentry/raven-node/blob/master/lib/parsers.js#L154 this results inreq.connection.remoteAddressbeing used.What is the expected behavior?
req.ipshouldn't be undefined and used.I've created a test case:
In an empty folder run
npm install express ravenCreate index.js with the following:
Visit / via the proxy and you'll see hello world and the IP printed
Visit /err via the proxy, it'll throw an error, check this in sentry it won't show the IP. I checked that the line mentioned above is resulting in req.ip undefined.
I've not had time to debug why req.ip is undefined but since it's not undefined when accessed outside raven I'm assuming it's a bug in raven.