chore(fetcher): set Origin header and add back proxy headers
This commit is contained in:
parent
8e791bbe24
commit
b313c4eb8d
2 changed files with 26 additions and 1 deletions
|
|
@ -26,8 +26,13 @@ describe('fetch', () => {
|
|||
'https://some-url.test/',
|
||||
{
|
||||
headers: {
|
||||
'Forwarded': 'for=127.0.0.1',
|
||||
'Origin': 'https://some-url.test',
|
||||
'User-Agent': expect.not.stringMatching(/jest/),
|
||||
'Referer': 'https://some-url.test',
|
||||
'X-Forwarded-For': '127.0.0.1',
|
||||
'X-Forwarded-Proto': 'https',
|
||||
'X-Real-IP': '127.0.0.1',
|
||||
},
|
||||
responseType: 'text',
|
||||
timeout: 15000,
|
||||
|
|
@ -52,8 +57,13 @@ describe('fetch', () => {
|
|||
},
|
||||
{
|
||||
headers: {
|
||||
'Forwarded': 'for=127.0.0.1',
|
||||
'Origin': 'https://some-url.test',
|
||||
'User-Agent': expect.not.stringMatching(/jest/),
|
||||
'Referer': 'https://some-url.test',
|
||||
'X-Forwarded-For': '127.0.0.1',
|
||||
'X-Forwarded-Proto': 'https',
|
||||
'X-Real-IP': '127.0.0.1',
|
||||
},
|
||||
responseType: 'text',
|
||||
timeout: 15000,
|
||||
|
|
@ -67,8 +77,13 @@ describe('fetch', () => {
|
|||
},
|
||||
{
|
||||
headers: {
|
||||
'Forwarded': 'for=127.0.0.1',
|
||||
'Origin': 'https://some-url.test',
|
||||
'User-Agent': 'jest',
|
||||
'Referer': 'https://some-url.test',
|
||||
'X-Forwarded-For': '127.0.0.1',
|
||||
'X-Forwarded-Proto': 'https',
|
||||
'X-Real-IP': '127.0.0.1',
|
||||
},
|
||||
responseType: 'text',
|
||||
timeout: 15000,
|
||||
|
|
@ -90,8 +105,13 @@ describe('fetch', () => {
|
|||
'https://some-url.test/',
|
||||
{
|
||||
headers: {
|
||||
'Forwarded': 'for=127.0.0.1',
|
||||
'Origin': 'https://some-url.test',
|
||||
'User-Agent': expect.not.stringMatching(/jest/),
|
||||
'Referer': 'https://some-url.test',
|
||||
'X-Forwarded-For': '127.0.0.1',
|
||||
'X-Forwarded-Proto': 'https',
|
||||
'X-Real-IP': '127.0.0.1',
|
||||
},
|
||||
responseType: 'text',
|
||||
timeout: 15000,
|
||||
|
|
|
|||
|
|
@ -40,8 +40,13 @@ export class Fetcher {
|
|||
timeout: 15000,
|
||||
...config,
|
||||
headers: {
|
||||
'User-Agent': this.createUserAgentForIp(ctx.ip),
|
||||
'Forwarded': `for=${ctx.ip}`,
|
||||
'Origin': `${url.origin}`,
|
||||
'Referer': `${url.origin}`,
|
||||
'User-Agent': this.createUserAgentForIp(ctx.ip),
|
||||
'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