File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -146,9 +146,14 @@ const rateLimitDefault = {
146
146
max : 1000 * maxMultiple ,
147
147
standardHeaders : true ,
148
148
legacyHeaders : false ,
149
- // Fly.io prevents spoofing of X-Forwarded-For
150
- // so no need to validate the trustProxy config
151
149
validate : { trustProxy : false } ,
150
+ // Malicious users can spoof their IP address which means we should not deault
151
+ // to trusting req.ip when hosted on Fly.io. However, users cannot spoof Fly-Client-Ip.
152
+ // When sitting behind a CDN such as cloudflare, replace fly-client-ip with the CDN
153
+ // specific header such as cf-connecting-ip
154
+ keyGenerator : ( req : express . Request ) => {
155
+ return req . get ( 'fly-client-ip' ) ?? `${ req . ip } `
156
+ } ,
152
157
}
153
158
154
159
const strongestRateLimit = rateLimit ( {
You can’t perform that action at this time.
0 commit comments