ServerlessRequest defines an ip property when it extends IncomingMessage. This property definition shadows the ip property defined by Express as noted at https://expressjs.com/en/api.html#req.ip.
By doing this, the Express trust proxy settings have no effect and the ip property does not reflect the IP address of the client that originally made the call.
Looking at the H4ad code base, it doesn't appear to use this ip property directly. If that's correct, can we change this implementation so it doesn't shadow the property defined by Express and maybe other libraries?
A few alternative ideas are:
- Don't define the
ip property at all.
- Define the
ip property if it doesn't exist already.
- Define a
remoteAddress property instead of an ip property.
serverless-adapter/src/network/request.ts
Line 78 in 3abab65
ServerlessRequestdefines anipproperty when it extendsIncomingMessage. This property definition shadows theipproperty defined by Express as noted at https://expressjs.com/en/api.html#req.ip.By doing this, the Express trust proxy settings have no effect and the
ipproperty does not reflect the IP address of the client that originally made the call.Looking at the H4ad code base, it doesn't appear to use this
ipproperty directly. If that's correct, can we change this implementation so it doesn't shadow the property defined by Express and maybe other libraries?A few alternative ideas are:
ipproperty at all.ipproperty if it doesn't exist already.remoteAddressproperty instead of anipproperty.