Skip to content

Commit 198f7aa

Browse files
authored
Merge pull request #19 from louije/claude/fix-rate-limit-proxy-iWtxU
Fix rate limiter to use real client IP behind Caddy proxy
2 parents fa297af + 623768d commit 198f7aa

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

backend/keystone.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ export default withAuth(config({
8383
credentials: true,
8484
},
8585
extendExpressApp: (app, context) => {
86+
// Trust first proxy (Caddy) to get real client IP from X-Forwarded-For
87+
app.set('trust proxy', 1);
88+
8689
// Parse cookies before any routes
8790
app.use(cookieParser());
8891

@@ -99,7 +102,7 @@ export default withAuth(config({
99102
// Rate limiting
100103
const apiLimiter = rateLimit({
101104
windowMs: 15 * 60 * 1000, // 15 minutes
102-
max: 500, // 500 requests per 15 min window
105+
max: 100, // 100 requests per 15 min window
103106
standardHeaders: true,
104107
legacyHeaders: false,
105108
message: { error: 'Too many requests, please try again later.' },
@@ -116,7 +119,7 @@ export default withAuth(config({
116119

117120
const uploadLimiter = rateLimit({
118121
windowMs: 60 * 60 * 1000, // 1 hour
119-
max: 200, // 200 uploads per hour
122+
max: 30, // 30 uploads per hour
120123
standardHeaders: true,
121124
legacyHeaders: false,
122125
message: { error: 'Upload limit reached. Please try again later.' },

0 commit comments

Comments
 (0)