req.ip
Purpose
The IP address of the client who sent this request (req
).
Note:
If the
trust proxy
option is disabled in Express, this is the "remote address". Otherwise, iftrust proxy
is enabled, this is the "upstream address". See Express docs for app.set() - in Sails this can be accomplished by adding the linesails.hooks.http.app.set('trust proxy', true);
toconfig/bootstrap.js
.
Usage
req.ip;
Example
req.ip;
// -> "127.0.0.1"