Consume headers for IP
This commit is contained in:
9
src/utils/ip.ts
Normal file
9
src/utils/ip.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Request } from 'express';
|
||||
|
||||
export const ipFromRequest = (req: Request): string | undefined => {
|
||||
const flyIp = req.headers['fly-client-ip'] as string | undefined;
|
||||
const forwardedFor = (req.headers['x-forwarded-for'] as string)?.split(
|
||||
',',
|
||||
)[0];
|
||||
return flyIp || forwardedFor || req.ip;
|
||||
};
|
Reference in New Issue
Block a user