fix(fetcher): do not overwrite config

This commit is contained in:
WebStreamr 2025-05-15 14:25:34 +00:00
parent acd29d8f39
commit e8ed101176
No known key found for this signature in database
2 changed files with 18 additions and 1 deletions

View file

@ -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',
},
},
);
});
});

View file

@ -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,
},
};
};