Skip to content

Commit 49ee18d

Browse files
author
Nicolas Dorseuil
committed
fix OGImage icon fetch
1 parent ba0094a commit 49ee18d

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

packages/gitbook/src/routes/ogimage.tsx

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { getAssetURL } from '@/lib/assets';
99
import { filterOutNullable } from '@/lib/typescript';
1010
import { getCacheTag } from '@gitbook/cache-tags';
1111
import type { GitBookSiteContext } from '@v2/lib/context';
12-
import { getCloudflareContext } from '@v2/lib/data/cloudflare';
1312
import { getResizedImageURL } from '@v2/lib/images';
1413

1514
const googleFontsMap: { [fontName in CustomizationDefaultFont]: string } = {
@@ -322,24 +321,6 @@ function logOnCloudflareOnly(message: string) {
322321
}
323322
}
324323

325-
/**
326-
* Fetch a resource from the function itself.
327-
* To avoid error with worker to worker requests in the same zone, we use the `WORKER_SELF_REFERENCE` binding.
328-
*/
329-
async function fetchSelf(url: string) {
330-
const cloudflare = getCloudflareContext();
331-
if (cloudflare?.env.WORKER_SELF_REFERENCE) {
332-
logOnCloudflareOnly(`Fetching self: ${url}`);
333-
return await cloudflare.env.WORKER_SELF_REFERENCE.fetch(
334-
// `getAssetURL` can return a relative URL, so we need to make it absolute
335-
// the URL doesn't matter, as we're using the worker-self-reference binding
336-
new URL(url, 'https://worker-self-reference/')
337-
);
338-
}
339-
340-
return await fetch(url);
341-
}
342-
343324
/**
344325
* Read an image from a response as a base64 encoded string.
345326
*/
@@ -377,7 +358,7 @@ async function readStaticImage(url: string) {
377358
* Read an image from GitBook itself.
378359
*/
379360
async function readSelfImage(url: string) {
380-
const response = await fetchSelf(url);
361+
const response = await fetch(url);
381362
const image = await readImage(response);
382363
return image;
383364
}

0 commit comments

Comments
 (0)