Skip to content

Commit

Permalink
IP address fix
Browse files Browse the repository at this point in the history
  • Loading branch information
muliswilliam committed Sep 18, 2023
1 parent 360e8a6 commit f1ba9d6
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,8 @@ export function addTimeToDate(
}

export function getClientInfo(req: NextApiRequest | IncomingMessage) {
let ipAddress = req.headers['x-real-ip'] as string

const forwardedFor = req.headers['x-forwarded-for'] as string
if (!ipAddress && forwardedFor) {
ipAddress = forwardedFor?.split(',').at(0) ?? ''
}

const clientInfo: ClientInfo = {
ipAddress,
ipAddress: req.socket.remoteAddress ?? '',
userAgent: req.headers['user-agent'] ?? '',
language: req.headers['accept-language'] ?? ''
}
Expand Down

0 comments on commit f1ba9d6

Please sign in to comment.