From 9fc3da0264cb7b7acc9ead19791bedb0dc567964 Mon Sep 17 00:00:00 2001 From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Thu, 22 Jun 2023 07:42:57 -0400 Subject: [PATCH] Fix grave `ReferenceError: fetch is not defined` error (#1460) * use cross-fetch * remove from utils usage --- src/server/handlers/catch-all-handler.tsx | 1 + src/server/handlers/manifest-handler.ts | 1 + src/server/utils/fetch-icon-png.ts | 2 ++ 3 files changed, 4 insertions(+) diff --git a/src/server/handlers/catch-all-handler.tsx b/src/server/handlers/catch-all-handler.tsx index b9ff13b..efadee4 100644 --- a/src/server/handlers/catch-all-handler.tsx +++ b/src/server/handlers/catch-all-handler.tsx @@ -1,5 +1,6 @@ import { initializeSite, isAuthPath } from "@utils/app"; import { ErrorPageData } from "@utils/types"; +import fetch from "cross-fetch"; import type { Request, Response } from "express"; import { StaticRouter, matchPath } from "inferno-router"; import { renderToString } from "inferno-server"; diff --git a/src/server/handlers/manifest-handler.ts b/src/server/handlers/manifest-handler.ts index 6858cff..b9a1108 100644 --- a/src/server/handlers/manifest-handler.ts +++ b/src/server/handlers/manifest-handler.ts @@ -1,3 +1,4 @@ +import fetch from "cross-fetch"; import type { Request, Response } from "express"; import { LemmyHttp } from "lemmy-js-client"; import { getHttpBaseExternal, getHttpBaseInternal } from "../../shared/env"; diff --git a/src/server/utils/fetch-icon-png.ts b/src/server/utils/fetch-icon-png.ts index 12b09e7..75497a2 100644 --- a/src/server/utils/fetch-icon-png.ts +++ b/src/server/utils/fetch-icon-png.ts @@ -1,3 +1,5 @@ +import fetch from "cross-fetch"; + export async function fetchIconPng(iconUrl: string) { return await fetch(iconUrl) .then(res => res.blob()) -- 2.44.1