Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

req-real-ip

lacherogwu69MIT1.0.4TypeScript support: included

This library allows you to get the real ip address of a user. It gives you the real ip address even if the request header is modified.

real, ip, address, request, header, modified, x-forwarded-for, x-real-ip, x-client-ip, x-proxy-user, x-cluster-client-ip, forwarded, user-ip, express-ip, express-real-ip, express-request-ip, express-real-ip-address, express-real-ip-address-middleware, express-real-ip-address-middleware-nodejs, express-real-ip-address-middleware-node, express-real-ip-address-middleware-js

readme

req-real-ip

This library allows you to get the real ip address of a user. It gives you the real ip address even if the request header is modified.

Usage

import express from 'express';
import realip from 'req-real-ip';

const app = express();

app.listen(3000, () => {
    console.log('Server is running');
});

app.use((req, res, next) => {
    res.json({
        user_ip: realip.detect({
            req: req,
            config: { cloudflare: false },
        }),
    });
});

cloudflare If you are using Cloudflare, the ip address is sent in the cf-connecting-ip variable in the header. However, if Cloudflare is not used, the request can be manipulated by changing the header information. For this reason, if you are not using Cloudflare, you should send false.