hanbinsite commited on
Commit
82371bf
·
1 Parent(s): 328d3a0

docs: add Cloudflare Worker script for web frontend proxy

Browse files
Files changed (1) hide show
  1. scripts/cloudflare-worker-web.js +23 -0
scripts/cloudflare-worker-web.js ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Cloudflare Worker - Web 前端反向代理
2
+ // 目标:www.hanbin666.top → binhugg4-web.hf.space
3
+ // 部署方式:Cloudflare Dashboard → Workers & Pages → Create Worker → 粘贴此代码
4
+ // 路由绑定:www.hanbin666.top/* 或 hanbin666.top/*
5
+
6
+ export default {
7
+ async fetch(request) {
8
+ const url = new URL(request.url);
9
+
10
+ url.hostname = "binhugg4-web.hf.space";
11
+ url.port = "443";
12
+ url.protocol = "https:";
13
+
14
+ const newRequest = new Request(url.toString(), {
15
+ method: request.method,
16
+ headers: request.headers,
17
+ body: ["GET", "HEAD"].includes(request.method) ? undefined : request.body,
18
+ redirect: "follow",
19
+ });
20
+
21
+ return fetch(newRequest);
22
+ },
23
+ };