0

Im wondering if user has no wifi and is only using his cellular network on his mobile device, the rate limiting will work / will there be a req.ip ?

const rateLimit = require('express-rate-limit')

const apiLimiter = rateLimit({
    windowMs: 15 * 60 * 1000, // 15 minutes
    max: 1, //this number is just for testing
    standardHeaders: true
    legacyHeaders: false, 
    keyGenerator: (req, res) => {
        return req.ip
    },
    handler: function(req, res, next) {
        throw new BaseError('too many requests', 429);
        next();
    },
})
learncode
  • 127
  • 6

1 Answers1

0

If a user is accessing your server over their cellular network on a mobile device, the rate limiting will still work, and the req.ip property will be available.

The IP will change however if they switch networks so their limit resets.

BGPHiJACK
  • 1,277
  • 1
  • 8
  • 16