From 2a1e1d6259c0a6096f0207e9bfc6de7d6aab82a4 Mon Sep 17 00:00:00 2001 From: 001ProMax <101964350+001ProMax@users.noreply.github.com> Date: Wed, 4 Mar 2026 16:04:09 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix(fetch):=20=E4=BC=98=E5=8C=96=20Node.js?= =?UTF-8?q?=20=E7=8E=AF=E5=A2=83=E4=B8=8B=E7=9A=84=20fetch=20=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91=20chore(prettier):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20.prettierignore=20=E6=96=87=E4=BB=B6=E4=BB=A5?= =?UTF-8?q?=E5=BF=BD=E7=95=A5=E6=89=80=E6=9C=89=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .prettierignore | 1 + polyfill/fetch.mjs | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..01b7e33 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +**/* \ No newline at end of file diff --git a/polyfill/fetch.mjs b/polyfill/fetch.mjs index ec96343..feb8707 100644 --- a/polyfill/fetch.mjs +++ b/polyfill/fetch.mjs @@ -215,9 +215,8 @@ export async function fetch(resource, options = {}) { }), ]); case "Node.js": { - const nodeFetch = globalThis.fetch ? globalThis.fetch : require("node-fetch"); - const fetchCookie = globalThis.fetchCookie ? globalThis.fetchCookie : require("fetch-cookie").default; - const fetch = fetchCookie(nodeFetch); + if (!globalThis.fetch) break; + const fetch = globalThis.fetch; // 转换请求参数 resource.timeout = resource.timeout * 1000; resource.redirect = resource.redirection ? "follow" : "manual"; From bd7a99ee0a160a84ecebc2a7d8ef0e2c3959ba1c Mon Sep 17 00:00:00 2001 From: 001ProMax <101964350+001ProMax@users.noreply.github.com> Date: Wed, 4 Mar 2026 21:35:25 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix(fetch):=20=E5=85=BC=E5=AE=B9=20Workers?= =?UTF-8?q?=20=E5=92=8C=20Vercel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- polyfill/fetch.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/polyfill/fetch.mjs b/polyfill/fetch.mjs index feb8707..df4f5a4 100644 --- a/polyfill/fetch.mjs +++ b/polyfill/fetch.mjs @@ -215,8 +215,13 @@ export async function fetch(resource, options = {}) { }), ]); case "Node.js": { - if (!globalThis.fetch) break; - const fetch = globalThis.fetch; + const fetch = (() => { + try { + return require("fetch-cookie").default(require("node-fetch")); + } catch { + return globalThis.fetch; + } + })(); // 转换请求参数 resource.timeout = resource.timeout * 1000; resource.redirect = resource.redirection ? "follow" : "manual"; From e09247a9bdd55f93d3bde4f2a3d1e0a42db60aac Mon Sep 17 00:00:00 2001 From: 001ProMax <101964350+001ProMax@users.noreply.github.com> Date: Wed, 4 Mar 2026 21:41:59 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix(fetch):=20=E6=B7=BB=E5=8A=A0=20fetch=20?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E6=80=A7=E6=A3=80=E6=9F=A5=E4=BB=A5=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- polyfill/fetch.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/polyfill/fetch.mjs b/polyfill/fetch.mjs index df4f5a4..40c8b7a 100644 --- a/polyfill/fetch.mjs +++ b/polyfill/fetch.mjs @@ -222,6 +222,7 @@ export async function fetch(resource, options = {}) { return globalThis.fetch; } })(); + if (!fetch) break; // 转换请求参数 resource.timeout = resource.timeout * 1000; resource.redirect = resource.redirection ? "follow" : "manual"; From b6991e323ae341f3c7cbb0cf54dbcd2eb762e03e Mon Sep 17 00:00:00 2001 From: 001ProMax <101964350+001ProMax@users.noreply.github.com> Date: Wed, 4 Mar 2026 21:49:27 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix(fetch):=20=E4=BC=98=E5=8C=96fetch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- polyfill/fetch.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/polyfill/fetch.mjs b/polyfill/fetch.mjs index 40c8b7a..6b41c60 100644 --- a/polyfill/fetch.mjs +++ b/polyfill/fetch.mjs @@ -215,11 +215,11 @@ export async function fetch(resource, options = {}) { }), ]); case "Node.js": { - const fetch = (() => { + const fetch = globalThis.fetch ?? (() => { try { return require("fetch-cookie").default(require("node-fetch")); } catch { - return globalThis.fetch; + return undefined; } })(); if (!fetch) break;