由於蜜柑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/