-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cannot access client ip from req.ip #13
Comments
before request to httpProxy, set client ip manually |
Tried, but doesn't work. You manage to get it to work? |
This is how I solved it, I store IP in request.headers['HTTP_CLIENT_IP'], but I think this should be done by this package. |
@RE-Roger Thanks for the response. I followed but still getting req.ip === undefined in my Express code. My code below:
I wonder what version of the library are you using? Mine was:
|
@newbaluku This library does not handle IP part for you, that's why I opened this issue. You need to get IP from the request headers you have set previously. Like the middleware below,
I haven't read through the express code, so I don't know the details about how express extract IP from the http request, maybe there is a header or something to let express handle the IP itself. But I do believe this should be done by the library. |
@RE-Roger Thanks, I see. But for some reason, I can't seems to be able to set req.ip. This field seems to be read-only to me.
console output:
but setting variable of a different name works. Separately, I have also investigated the header value of X-Forwarded-For and found that it's undefined. Maybe the problem lies here where the gateway/proxy doesn't pass on the ip address to the function compute instance and causes Express's req.ip to be undefined. |
@newbaluku Thanks for pointing out my error, the code I wrote is just for demonstration, I haven't checked them. |
client IP is stored at request.headers['HTTP_CLIENT_IP'].
I naturally think I can access the client IP from express req.ip, but I can't.
Seems the project filter this header.
I think this feature is necessary.
The text was updated successfully, but these errors were encountered: