Skip to content

Commit

Permalink
fix: Only read the first ip of the x-forwarded-for header (#9545)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dschoordsch committed Mar 18, 2024
1 parent 0217e11 commit 081f7a0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/server/utils/uwsGetIP.ts
@@ -1,7 +1,7 @@
import {HttpRequest, HttpResponse} from 'uWebSockets.js'

const uwsGetIP = (res: HttpResponse, req: HttpRequest) => {
const clientIp = req.getHeader('x-forwarded-for')
const clientIp = req.getHeader('x-forwarded-for')?.split(',')[0]
if (clientIp) return clientIp
// returns ipv6 e.g. '0000:0000:0000:0000:0000:ffff:ac11:0001'
return Buffer.from(res.getRemoteAddressAsText()).toString()
Expand Down

0 comments on commit 081f7a0

Please sign in to comment.