chore(fetcher): remove Origin header

more is not always better I guess :)

not breaking anything, but that header is not used for normal HTTP GET
requests
This commit is contained in:
WebStreamr 2025-06-01 13:08:52 +00:00
parent a85a483732
commit ca981220c9
No known key found for this signature in database
2 changed files with 14 additions and 22 deletions

View file

@ -28,7 +28,6 @@ describe('fetch', () => {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en',
'Forwarded': 'for=127.0.0.1',
'Origin': 'https://some-url.test',
'Priority': 'u=0',
'Referer': 'https://some-url.test',
'X-Forwarded-For': '127.0.0.1',
@ -57,7 +56,6 @@ describe('fetch', () => {
expect(fetchMock.callHistory.callLogs[0]?.args[1]).toMatchObject({
headers: {
Origin: 'https://example.com',
Referer: 'https://example.com/foo/bar',
},
});

View file

@ -28,26 +28,20 @@ export class Fetcher {
return (await this.cachedFetch(ctx, url, { ...init, method: 'HEAD' })).policy.responseHeaders();
};
private readonly getInit = (ctx: Context, url: URL, init?: RequestInit): RequestInit => {
const origin = ctx.referer?.origin ?? url.origin;
const referer = ctx.referer?.href ?? url.origin;
return {
...init,
headers: {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en',
'Forwarded': `for=${ctx.ip}`,
'Origin': `${origin}`,
'Priority': 'u=0',
'Referer': `${referer}`,
'X-Forwarded-For': ctx.ip,
'X-Forwarded-Proto': url.protocol.slice(0, -1),
'X-Real-IP': ctx.ip,
...init?.headers,
},
};
};
private readonly getInit = (ctx: Context, url: URL, init?: RequestInit): RequestInit => ({
...init,
headers: {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en',
'Forwarded': `for=${ctx.ip}`,
'Priority': 'u=0',
'Referer': `${ctx.referer?.href ?? url.origin}`,
'X-Forwarded-For': ctx.ip,
'X-Forwarded-Proto': url.protocol.slice(0, -1),
'X-Real-IP': ctx.ip,
...init?.headers,
},
});
private readonly handleHttpCacheItem = (httpCacheItem: HttpCacheItem): HttpCacheItem => {
if (httpCacheItem.status && httpCacheItem.status >= 200 && httpCacheItem.status <= 299) {