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

Commit 68e2ff6

Browse files
committed
fuck the fetch
1 parent c0ca623 commit 68e2ff6

File tree

4 files changed

+123
-1
lines changed

4 files changed

+123
-1
lines changed

next.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ const nextConfig = {
1313
},
1414

1515
webpack: (config, options) => {
16+
if (options.isServer) {
17+
const originalEntry = config.entry;
18+
config.entry = async () => {
19+
const entries = await originalEntry();
20+
if (entries["pages/_app"]) {
21+
entries["pages/_app"].unshift("./src/fuck-the-fetch.ts");
22+
}
23+
24+
return entries;
25+
};
26+
}
27+
1628
config.module.rules.push({
1729
test: /\.yml/,
1830
use: "yaml-loader",

package-lock.json

Lines changed: 86 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"negotiator": "^0.6.3",
4343
"next": "13.2.3",
4444
"next-sitemap": "^4.0.2",
45+
"node-fetch": "^3.3.1",
4546
"openai": "^3.2.1",
4647
"papaparse": "^5.4.0",
4748
"react": "18.2.0",

src/fuck-the-fetch.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import fetch, {
2+
Blob,
3+
blobFrom,
4+
blobFromSync,
5+
File,
6+
fileFrom,
7+
fileFromSync,
8+
FormData,
9+
Headers,
10+
Request,
11+
Response,
12+
} from "node-fetch";
13+
14+
(globalThis as any).fetch = fetch;
15+
(globalThis as any).Blob = Blob;
16+
(globalThis as any).blobFrom = blobFrom;
17+
(globalThis as any).blobFromSync = blobFromSync;
18+
(globalThis as any).File = File;
19+
(globalThis as any).fileFrom = fileFrom;
20+
(globalThis as any).fileFromSync = fileFromSync;
21+
(globalThis as any).FormData = FormData;
22+
(globalThis as any).Headers = Headers;
23+
(globalThis as any).Request = Request;
24+
(globalThis as any).Response = Response;

0 commit comments

Comments
 (0)