Spaces:
Running
Running
Update server.js
Browse files
server.js
CHANGED
@@ -16,7 +16,7 @@ let ipConfigurations = {};
|
|
16 |
// Rate limit middleware
|
17 |
app.use('/api', (req, res, next) => {
|
18 |
const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
19 |
-
const config = ipConfigurations[ip] || { limit:
|
20 |
|
21 |
if (new Date() < new Date(config.nextAvailableTime) || config.requestCount >= config.limit) {
|
22 |
return res.status(429).json({
|
|
|
16 |
// Rate limit middleware
|
17 |
app.use('/api', (req, res, next) => {
|
18 |
const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
19 |
+
const config = ipConfigurations[ip] || { limit: 2, requestCount: 0, nextAvailableTime: Date.now() };
|
20 |
|
21 |
if (new Date() < new Date(config.nextAvailableTime) || config.requestCount >= config.limit) {
|
22 |
return res.status(429).json({
|