From e8ed101176bda776b1650ed1d561affa8070963c Mon Sep 17 00:00:00 2001 From: WebStreamr <210764791+webstreamr@users.noreply.github.com> Date: Thu, 15 May 2025 14:25:34 +0000 Subject: [PATCH] fix(fetcher): do not overwrite config --- src/utils/Fetcher.test.ts | 17 +++++++++++++++++ src/utils/Fetcher.ts | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) 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, }, }; };