用CFworkers部署的所以不用担心泄露账号密码问题

chen'mo
2023-05-25 / 0 评论 / 20,187 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2023年05月26日,已超过563天没有更新,若内容或图片失效,请留言反馈。

用CFworkers部署的所以不用担心泄露账号密码问题

所有功能正常
源码:
https://bijici.com/6wmzHview

https://hostloc.us/

备份:

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request));
});

const TARGET_URL = "https://hostloc.com";
const TARGET_URL_REGEXP = /hostloc\.com/g;
const TARGET_HOSTNAME = new URL(TARGET_URL).hostname;

const handleRequest = async request => {
  const url = new URL(request.url);
  url.hostname = TARGET_HOSTNAME;

  let headers = new Headers(request.headers);
  headers.set("Referer", TARGET_URL);
  headers.set("User-Agent", request.headers.get("user-agent"));

  const param = {
    method: request.method,
    headers: headers,
    body: request.body,
    redirect: "manual"
  }

  const response = await fetch(url, param);
  return handleResponse(request, response);
}

const handleResponse = async (request, response) => {
  const contentType = response.headers.get('content-type');

  let headers = new Headers(response.headers);
  headers.set('Access-Control-Allow-Origin', '*');
  headers.set('Access-Control-Allow-Methods', 'GET'); 
  headers.set('Access-Control-Allow-Headers', 'Content-Type');

  let location = response.headers.get('location');
  if (location) {
    location = location.replace(TARGET_URL_REGEXP, new URL(request.url).hostname);
    headers.set('location', location);
  }

  const data = (contentType && contentType.includes('text')) ? await response.text() : await response.blob();
  const modifiedData = (typeof data === 'string') ? data.replace(TARGET_URL_REGEXP, new URL(request.url).hostname) : data;

  return new Response(modifiedData, {
    status: response.status,
    statusText: response.statusText,
    headers: headers
  });
}

PS:我自己也弄了一个反代:https://mjj.513513.xyz

0
HTML5实现微信聊天气泡效果
« 上一篇 05-21
worker反代Loc,解决不能发帖和投票的 问题
下一篇 » 05-26

评论 (0)

插入图片