From 9afdee1cf673df0ad0e5be1318a7db3788e6a98a Mon Sep 17 00:00:00 2001 From: Jurangren Date: Fri, 22 Aug 2025 02:33:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=A0=B9=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E9=87=8D=E5=AE=9A=E5=90=91=E4=B8=8E=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=A2=9E=E5=BC=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 在根路径 '/' 访问时,自动重定向到主页 'https://searchgal.homes'。 * 在 `logToCF` 函数中添加 `console.log`,方便在 Cloudflare 控制台查看日志。 --- src/index.ts | 4 ++++ src/utils/httpClient.ts | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/index.ts b/src/index.ts index 0c7e187..99e6e60 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,6 +54,10 @@ export default { async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise { const url = new URL(request.url); + if (url.pathname === '/') { + return Response.redirect('https://searchgal.homes', 302); + } + if (request.method === "OPTIONS") { return new Response(null, { headers: corsHeaders }); } diff --git a/src/utils/httpClient.ts b/src/utils/httpClient.ts index 7a5c81e..4fcf320 100644 --- a/src/utils/httpClient.ts +++ b/src/utils/httpClient.ts @@ -44,6 +44,8 @@ export async function fetchClient( * @param data 要记录的数据对象。 */ export async function logToCF(data: object) { + // 在此处添加 console.log,以便在 Cloudflare 控制台也能看到日志 + console.log(JSON.stringify(data)); try { await fetch("https://log.gal.homes", { method: "POST",