fix: set trust proxy for rate limiter

This commit is contained in:
mstfyldz
2026-08-08 17:48:45 +03:00
parent 633f66b09b
commit afbfb413ce
+6 -1
View File
@@ -12,12 +12,17 @@ const port = process.env.PORT || 3001;
// P0-6: Rate Limiting // P0-6: Rate Limiting
const limiter = rateLimit({ const limiter = rateLimit({
windowMs: 24 * 60 * 60 * 1000, // 24 hours windowMs: 24 * 60 * 60 * 1000, // 24 hours
max: 200, // limit each IP to 200 requests per windowMs max: 5000, // limit each IP to 5000 requests per windowMs (increased for dev/testing)
message: { error: 'Günlük kullanım limitine ulaştınız. (Too many requests)' } message: { error: 'Günlük kullanım limitine ulaştınız. (Too many requests)' }
}); });
app.use(cors()); app.use(cors());
app.use(express.json()); app.use(express.json());
// If your app is behind a proxy (like Nginx, Docker ingress, etc.),
// the IP will default to the proxy's IP. We set trust proxy to get the real client IP.
app.set('trust proxy', 1);
app.use(limiter); // Apply rate limiting to all requests app.use(limiter); // Apply rate limiting to all requests
// Mount all API routes // Mount all API routes