diff --git a/lib/utils.ts b/lib/utils.ts index 9773b7b..8e26ea6 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -235,15 +235,23 @@ export function extractTime(timeRange: string, is24: boolean): string[] { async function _fetchWebPage(pageUrl: string): Promise { try { + const fetchParams = + typeof window !== "undefined" ? + [ + `https://asia-south1-bonse-430603.cloudfunctions.net/rjs-proxy`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ url: pageUrl }), + }, + ] + : [pageUrl, {}]; + const response = await fetch( - `https://asia-south1-bonse-430603.cloudfunctions.net/rjs-proxy`, - { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ url: pageUrl }), - }, + fetchParams[0] as string, + fetchParams[1] as Record, ); if (!response.ok) { diff --git a/test/browser.test.ts b/test/browser.test.ts index f8a1e47..1ce58bd 100644 --- a/test/browser.test.ts +++ b/test/browser.test.ts @@ -129,4 +129,4 @@ async function runAll() { test("InAction (Browser) test", async () => { expect(await runAll()).toBe("passed"); -}, 30000); +}, 60000);