admin / scripts /deploy /cloudflare-worker-admin.js
hanbinsite's picture
chore: HuggingFace deploy 2026-05-19 10:37
dc649b1
Raw History Blame Contribute Delete
927 Bytes
// Cloudflare Worker - Admin 前端反向代理
// 目标:admin.hanbin666.top → binhugg3-admin.hf.space
// 部署方式:Cloudflare Dashboard → Workers & Pages → Create Worker → 粘贴此代码
// 路由绑定:admin.hanbin666.top/*
export default {
async fetch(request) {
const url = new URL(request.url);
// 替换目标域名
url.hostname = "binhugg3-admin.hf.space";
url.port = "443";
url.protocol = "https:";
const newRequest = new Request(url.toString(), {
method: request.method,
headers: request.headers,
body: ["GET", "HEAD"].includes(request.method) ? undefined : request.body,
redirect: "follow",
});
const response = await fetch(newRequest);
const newResponse = new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: response.headers,
});
return newResponse;
},
};