View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page

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, if trust proxy is enabled, this is the "upstream address". See Express docs for app.set() - in Sails this can be accomplished by adding the line sails.hooks.http.app.set('trust proxy', true); to config/bootstrap.js.

Usage

req.ip;

Example

req.ip;
// -> "127.0.0.1"

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Reference

We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book