Skip to content

Commit

Permalink
Merge pull request #892 from Journaly/debug-get-id
Browse files Browse the repository at this point in the history
Fix Getting Posting IP Address
  • Loading branch information
robin-macpherson authored Sep 12, 2024
2 parents 4a9654e + 5fb8306 commit 866fc1d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/web/resolvers/utils/getPostingIpAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ const isNextRequest = (req: NextRequest | Request): req is NextRequest => {
export const getPostingIpAddress = (req: NextRequest | Request) => {
if (isNextRequest(req)) return req.ip

const headers = req?.headers['X-Forwarded-For']
const headers =
req?.headers['x-forwarded-for'] ||
req?.headers['x-real-ip'] ||
req?.headers['X-Forwarded-For'] ||
req?.headers['X-Real-IP']
if (typeof headers === 'string') return headers.split(',')?.[0]

return undefined
Expand Down

0 comments on commit 866fc1d

Please sign in to comment.