Skip to content

Commit

Permalink
Proxy blocking node environment - fixed and closes #22
Browse files Browse the repository at this point in the history
  • Loading branch information
darsan-in committed Nov 22, 2024
1 parent 1e0252b commit 69ad1cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
24 changes: 16 additions & 8 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,23 @@ export function extractTime(timeRange: string, is24: boolean): string[] {

async function _fetchWebPage(pageUrl: string): Promise<string> {
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<string, any>,
);

if (!response.ok) {
Expand Down
2 changes: 1 addition & 1 deletion test/browser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ async function runAll() {

test("InAction (Browser) test", async () => {
expect(await runAll()).toBe("passed");
}, 30000);
}, 60000);

0 comments on commit 69ad1cc

Please sign in to comment.