Use x-forwarded-for
This commit is contained in:
parent
aea8e3aca8
commit
9165dcf62e
|
@ -1,12 +1,13 @@
|
||||||
import { Context } from '../trpc'
|
import { Context } from '../trpc'
|
||||||
|
|
||||||
export function getIpFromContext({ req }: Context) {
|
export function getIpFromContext({ req }: Context) {
|
||||||
|
if (process.env.NODE_ENV === 'development') return '10.7.16.254'
|
||||||
|
|
||||||
let ip: string = ''
|
let ip: string = ''
|
||||||
|
|
||||||
if (req.ips[0]) ip = req.ips[0]
|
if (req.headers['x-forwarded-for'])
|
||||||
else ip = req.ip
|
ip = req.headers['x-forwarded-for'] as string
|
||||||
|
else ip = req.ip.split('::ffff:')[1]
|
||||||
if (process.env.NODE_ENV === 'development') return '10.7.16.254'
|
|
||||||
|
|
||||||
return ip
|
return ip
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user