From 7c0b455407647433084c184b4b9cd147def00b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= Date: Tue, 15 Jul 2025 22:49:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20worker.js=20=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=20fetch=20=E5=87=BD=E6=95=B0=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=93=8D=E5=BA=94=E5=86=85=E5=AE=B9=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/worker.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/worker.js b/src/worker.js index 7799892..0fbd27a 100644 --- a/src/worker.js +++ b/src/worker.js @@ -1,17 +1,21 @@ export default { - async fetch(request, env, ctx) { + async fetch(request, env, ctx) { const url = new URL(request.url); console.log('url :>> ', url); - if ("/" === url.pathname) { - return new Response(`curl -fsSL ${url.origin}/install.sh | sh - -iwr ${url.origin}/install.ps1 -useb | iex`); - } + if ('/' === url.pathname) { + return new Response(`curl -fsSL ${url.origin}/install.sh | sh - +iwr ${url.origin}/install.ps1 -useb | iex + +pnpm config get registry +pnpm config set registry https://registry.npmmirror.com +`); + } let response = await fetch(`http://get.pnpm.io${url.pathname}`); let text = await response.text(); - text = text.replace(/https:\/\/github.com/g, "https://gh-cf.oo1.dev/https://github.com"); - text=text.replace('Downloading pnpm from GitHub','Downloading pnpm from GitHub (via Cloudflare)'); - text=text.replace('Downloading pnpm','Downloading pnpm (via Cloudflare)'); + text = text.replace(/https:\/\/github.com/g, 'https://gh-cf.oo1.dev/https://github.com'); + text = text.replace('Downloading pnpm from GitHub', 'Downloading pnpm from GitHub (via Cloudflare)'); + text = text.replace('Downloading pnpm', 'Downloading pnpm (via Cloudflare)'); return new Response(text); - }, + }, };