fix login error
This commit is contained in:
@@ -8,6 +8,9 @@ import { errorHandler, notFoundHandler } from './middleware/error.middleware';
|
||||
|
||||
const app: Application = express();
|
||||
|
||||
// Trust proxy (required for correct IP detection behind Traefik/Nginx)
|
||||
app.set('trust proxy', 1);
|
||||
|
||||
// Security middleware
|
||||
app.use(helmet());
|
||||
|
||||
@@ -17,7 +20,7 @@ app.use(cors({
|
||||
credentials: true,
|
||||
}));
|
||||
|
||||
// Rate limiting
|
||||
// Rate limiting - general API routes
|
||||
const limiter = rateLimit({
|
||||
windowMs: environment.rateLimit.windowMs,
|
||||
max: environment.rateLimit.max,
|
||||
@@ -26,6 +29,16 @@ const limiter = rateLimit({
|
||||
legacyHeaders: false,
|
||||
});
|
||||
|
||||
// Rate limiting - auth routes (more generous to avoid blocking logins)
|
||||
const authLimiter = rateLimit({
|
||||
windowMs: 15 * 60 * 1000, // 15 minutes
|
||||
max: 30, // 30 auth attempts per window
|
||||
message: 'Zu viele Anmeldeversuche. Bitte versuchen Sie es später erneut.',
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false,
|
||||
});
|
||||
|
||||
app.use('/api/auth', authLimiter);
|
||||
app.use('/api', limiter);
|
||||
|
||||
// Body parsing middleware
|
||||
|
||||
Reference in New Issue
Block a user