diff --git a/src/utils/Fetcher.test.ts b/src/utils/Fetcher.test.ts index 4388c4c..e98dcee 100644 --- a/src/utils/Fetcher.test.ts +++ b/src/utils/Fetcher.test.ts @@ -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', + }, + }, + ); }); }); diff --git a/src/utils/Fetcher.ts b/src/utils/Fetcher.ts index 9ef1d82..2820d56 100644 --- a/src/utils/Fetcher.ts +++ b/src/utils/Fetcher.ts @@ -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, }, }; };