由于蜜柑RSS的订阅遭到GFW的封锁,大部分部署在国内的自动下载RSS应该都无法连接失效了
1.注册cloudflare#
2.启用Workers#
const TELEGRAPH_URL = 'https://mikanani.me';
const MY_DOMAIN = 'https://yourdomain.com'
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const url = new URL(request.url);
url.host = TELEGRAPH_URL.replace(/^https?:\/\//, '');
const modifiedRequest = new Request(url.toString(), {
headers: request.headers,
method: request.method,
body: request.body,
redirect: 'manual'
});
const response = await fetch(modifiedRequest);
const contentType = response.headers.get('Content-Type') || '';
// 如果内容类型是 RSS,才进行替换操作
if (contentType.includes('application/xml')) {
const text = await response.text();
const replacedText = text.replace(/https?:\/\/mikanani\.me/g, MY_DOMAIN);
const modifiedResponse = new Response(replacedText, response);
// 添加允许跨域访问的响应头
modifiedResponse.headers.set('Access-Control-Allow-Origin', '*');
return modifiedResponse;
} else {
const modifiedResponse = new Response(response.body, response);
// 添加允许跨域访问的响应头
modifiedResponse.headers.set('Access-Control-Allow-Origin', '*');
return modifiedResponse;
}
}
解析设置自定义域名#
因为workers.dev 域名本身也是被墙的因此我们需要更换自己的没被墙的域名
成功示例#
当然,你也可以使用别人现成已搭建好的反代。
反代地址:https://mikan.catcat.blog/