diff --git a/src/utils/Fetcher.test.ts b/src/utils/Fetcher.test.ts index 89f9f43..19068c6 100644 --- a/src/utils/Fetcher.test.ts +++ b/src/utils/Fetcher.test.ts @@ -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', }, }); diff --git a/src/utils/Fetcher.ts b/src/utils/Fetcher.ts index b1a964e..86a4584 100644 --- a/src/utils/Fetcher.ts +++ b/src/utils/Fetcher.ts @@ -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) {