From 35639354e2583ed03c0ea87024be7769f07c80ad Mon Sep 17 00:00:00 2001 From: XUZHONGXIN Date: Fri, 5 Sep 2025 14:36:04 +0800 Subject: [PATCH] Update uptime.config.ts --- uptime.config.ts | 58 ++---------------------------------------------- 1 file changed, 2 insertions(+), 56 deletions(-) diff --git a/uptime.config.ts b/uptime.config.ts index 016220a..36a27d9 100644 --- a/uptime.config.ts +++ b/uptime.config.ts @@ -247,59 +247,5 @@ const maintenances: MaintenanceConfig[] = [ }, ] -export default { - async fetch(request, env, ctx) { - const targetDomain = "http://se-xl-services.xinnew.top"; // 你的目标域名 - const url = new URL(request.url); - - // 处理预检请求 - if (request.method === "OPTIONS") { - return new Response(null, { - status: 204, - headers: corsHeaders() - }); - } - - // 构造目标 URL - const path = url.pathname + url.search; - const proxyUrl = targetDomain + path; - - try { - const res = await fetch(proxyUrl, { - method: request.method, - headers: request.headers, - body: request.method !== "GET" && request.method !== "HEAD" ? request.body : undefined, - redirect: "follow" - }); - - // 复制原始响应头 - const headers = new Headers(res.headers); - - // 添加 CORS - headers.set("Access-Control-Allow-Origin", "*"); - headers.set("Access-Control-Allow-Methods", "GET,HEAD,POST,PUT,DELETE,OPTIONS"); - headers.set("Access-Control-Allow-Headers", "*"); - - // 返回响应 - return new Response(res.body, { - status: res.status, - statusText: res.statusText, - headers - }); - - } catch (err) { - return new Response(`Error fetching ${proxyUrl}: ${err.message}`, { - status: 500, - headers: corsHeaders() - }); - } - } -}; - -function corsHeaders() { - return { - "Access-Control-Allow-Origin": "*", - "Access-Control-Allow-Methods": "GET,HEAD,POST,PUT,DELETE,OPTIONS", - "Access-Control-Allow-Headers": "*" - }; -} +// Don't forget this, otherwise compilation fails. +export { pageConfig, workerConfig, maintenances }