Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit 8283e72

Browse files
committed
fuck the fetch
1 parent c1d7001 commit 8283e72

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/api/user.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { SITE_INTERNAL_HEADER_URL } from "@/configs/constants";
2+
import fetch from "node-fetch";
23

34
export async function logout() {
45
const response = await fetch("/api/chatgpt/user", {
@@ -19,8 +20,8 @@ export async function login(key: string) {
1920
}),
2021
}).then((it) => it.json());
2122

22-
if (response.error) {
23-
alert("Error(login): " + JSON.stringify(response.error));
23+
if ((response as any).error) {
24+
alert("Error(login): " + JSON.stringify((response as any).error));
2425
return;
2526
}
2627

@@ -35,10 +36,11 @@ export async function isLoggedIn(hashedKey?: string) {
3536
body: hashedKey ?? "NOPE",
3637
}).then((it) => it.json());
3738

38-
return response.loggedIn;
39+
return (response as any).loggedIn;
3940
}
4041

4142
console.log(process.version);
43+
console.log("patched: ", (fetch as any).__XX_PATCHED__)
4244
console.log("key", hashedKey);
4345
const { headers } = await import("next/headers");
4446
console.log("headers", headers);
@@ -53,5 +55,5 @@ export async function isLoggedIn(hashedKey?: string) {
5355
redirect: "follow",
5456
}).then((it) => it.json());
5557
console.log("response", response);
56-
return response.loggedIn;
58+
return (response as any).loggedIn;
5759
}

src/fuck-the-fetch.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import fetch, {
1111
Response,
1212
} from "node-fetch";
1313

14+
(fetch as any).__XX_PATCHED__ = true;
1415
(globalThis as any).fetch = fetch;
1516
(globalThis as any).Blob = Blob;
1617
(globalThis as any).blobFrom = blobFrom;

0 commit comments

Comments
 (0)