fix(fetcher): do not overwrite config
This commit is contained in:
parent
acd29d8f39
commit
e8ed101176
2 changed files with 18 additions and 1 deletions
|
|
@ -62,5 +62,22 @@ describe('fetch', () => {
|
|||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(axiosSpy).toHaveBeenCalledWith(
|
||||
'https://some-url.test/',
|
||||
{
|
||||
foo: 'bar',
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'User-Agent': 'jest',
|
||||
'Forwarded': 'for=127.0.0.1',
|
||||
'Referer': 'https://some-url.test',
|
||||
'X-Forwarded-For': '127.0.0.1',
|
||||
'X-Forwarded-Proto': 'https',
|
||||
'X-Real-IP': '127.0.0.1',
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,13 +37,13 @@ export class Fetcher {
|
|||
return {
|
||||
...config,
|
||||
headers: {
|
||||
...config?.headers,
|
||||
'User-Agent': this.createUserAgentForIp(ctx.ip),
|
||||
'Forwarded': `for=${ctx.ip}`,
|
||||
'Referer': `${url.protocol}//${url.host}`,
|
||||
'X-Forwarded-For': ctx.ip,
|
||||
'X-Forwarded-Proto': url.protocol.slice(0, -1),
|
||||
'X-Real-IP': ctx.ip,
|
||||
...config?.headers,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue