侧边栏壁纸
博主头像
土拨鼠说Halo 博主等级

行动起来,活在当下

  • 累计撰写 42 篇文章
  • 累计创建 3 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

[转载]利用Worker反代github

土拨鼠
2025-02-22 / 0 评论 / 0 点赞 / 0 阅读 / 0 字

教程 #脚本 #反代

实现的步骤就是步骤的实现:

第一步,绑定你的域名到cloudflare。

第二步,创建一个worker,并写入如下代码:

export default {
async fetch(request, env) {

const _url = new URL(request.url);
const hostname = _url.hostname
_url.hostname = "github.com"
const req = new Request(_url, request);
req.headers.set('origin', 'https://github.com');

const res = await fetch(req);
let newres = new Response(res.body, res);

let location = newres.headers.get('location');
if (location !== null && location !== "") {
  location = location.replace('://github.com', '://'+hostname);
  newres.headers.set('location', location);
}
return newres 

},
};

第三步,自定义域名,方便访问。

利用 Cloudflare worker 或 pages 免费服务反代 GitHub | 搜百谷 221

0

评论区