diff --git a/packages/gitbook/src/lib/images/resizer/cf-fetch.ts b/packages/gitbook/src/lib/images/resizer/cf-fetch.ts deleted file mode 100644 index 7c87c15ce..000000000 --- a/packages/gitbook/src/lib/images/resizer/cf-fetch.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { CloudflareImageOptions } from './types'; -import { copyImageResponse } from './utils'; -import { getLogger } from '@/lib/logger'; - -/** - * Resize an image by doing a request to the image itself using the Cloudflare fetch. - * https://developers.cloudflare.com/images/transform-images/transform-via-workers/ - */ -export async function resizeImageWithCFFetch( - input: string, - options: CloudflareImageOptions & { - signal?: AbortSignal; - } -): Promise { - const { signal, ...resizeOptions } = options; - - const logger = getLogger().subLogger('imageResizing'); - logger.log(`resize image using cf-fetch: ${input}`); - - return copyImageResponse( - await fetch(input, { - headers: { - // Pass the `Accept` header, as Cloudflare uses this to validate the format. - Accept: - resizeOptions.format === 'json' - ? 'application/json' - : `image/${resizeOptions.format || 'jpeg'}`, - }, - signal, - cf: { image: resizeOptions }, - }) - ); -} diff --git a/packages/gitbook/src/lib/images/resizer/resizeImage.ts b/packages/gitbook/src/lib/images/resizer/resizeImage.ts index 34a3bf228..5c0ddb0cf 100644 --- a/packages/gitbook/src/lib/images/resizer/resizeImage.ts +++ b/packages/gitbook/src/lib/images/resizer/resizeImage.ts @@ -3,7 +3,6 @@ import assertNever from 'assert-never'; import { GITBOOK_IMAGE_RESIZE_MODE } from '../../env'; import { SizableImageAction, checkIsSizableImageURL } from '../checkIsSizableImageURL'; -import { resizeImageWithCFFetch } from './cf-fetch'; import { resizeImageWithGitbookServices } from './gitbook-service'; import type { CloudflareImageJsonFormat, CloudflareImageOptions } from './types'; import { getLogger } from '@/lib/logger'; @@ -73,7 +72,6 @@ export async function resizeImage( switch (GITBOOK_IMAGE_RESIZE_MODE) { case 'cf-fetch': - return resizeImageWithCFFetch(input, options); case 'gitbook-service': case 'cdn-cgi': return resizeImageWithGitbookServices(input, options);