for this challenge:
whose IP gets printed and how can I see that?
for this challenge:
whose IP gets printed and how can I see that?
In a real (non-glitch) nodejs app that you deploy to a server, the ip
property attached to the req
object should be that of the client’s making the request to the server. However glitch sets the X-Forwarded-For header for incoming requests and req.ip
only gives ::ffff:127.0.0.1
or some local rendition of that, to get your true ip address in glitch use req.headers['x-forwarded-for'])
and find it in there.
edit: Note also, the trust proxy setting must also be enabled for req.ip
to work
When the
trust proxy
setting does not evaluate tofalse
, the value of this property is derived from the left-most entry in theX-Forwarded-For
header. This header can be set by the client or by the proxy.
You can get the status of ‘trust proxy’ with app.disabled('trust proxy')
, in other words if you do a app.enable('trust proxy')
at the top, req.ip
will also give you your true ip address even in glitch.