Fix custom CLIENT_IP_HEADER not parsing x-forwarded-for/forwarded chains
This commit is contained in:
1 parent
af1b6c6efc
commit
65b508c22a
2 files changed
+24
-14
No files matched your search
@@ -24,6 +24,14 @@ test('getIpAddress: Custom header', () => {
|
||||
expect(getIpAddress(new Headers({ 'x-custom-ip-header': IP }))).toEqual(IP);
|
||||
});
|
||||
|
||||
test('getIpAddress: Custom header set to x-forwarded-for uses leftmost IP in chain', () => {
|
||||
process.env.CLIENT_IP_HEADER = 'x-forwarded-for';
|
||||
|
||||
expect(
|
||||
getIpAddress(new Headers({ 'x-forwarded-for': `${IP}, 10.0.0.1, 10.0.0.2` })),
|
||||
).toEqual(IP);
|
||||
});
|
||||
|
||||
test('getIpAddress: CloudFlare header', () => {
|
||||
expect(getIpAddress(new Headers({ 'cf-connecting-ip': IP }))).toEqual(IP);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user