mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 08:12:00 +02:00

* feat: bun 🥟
* check if playwright/linux workflow is fixed
* fix: backend issues exposed by bun
* feat: update scripts for bun
16 lines
598 B
JavaScript
16 lines
598 B
JavaScript
const rateLimit = require('express-rate-limit');
|
|
const windowMs = (process.env?.LOGIN_WINDOW ?? 5) * 60 * 1000; // default: 5 minutes
|
|
const max = process.env?.LOGIN_MAX ?? 7; // default: limit each IP to 7 requests per windowMs
|
|
const windowInMinutes = windowMs / 60000;
|
|
|
|
const loginLimiter = rateLimit({
|
|
windowMs,
|
|
max,
|
|
message: `Too many login attempts from this IP, please try again after ${windowInMinutes} minutes.`,
|
|
keyGenerator: function (req) {
|
|
// Strip out the port number from the IP address
|
|
return req.ip.replace(/:\d+[^:]*$/, '');
|
|
},
|
|
});
|
|
|
|
module.exports = loginLimiter;
|