fix(route/telegram): workaround t.me issue (#22717)

This commit is contained in:
Tony
2026-07-14 20:37:11 +08:00
committed by GitHub
parent 7379888d01
commit 2266ac7ec8
+9 -2
View File
@@ -1,6 +1,7 @@
import querystring from 'node:querystring';
import { load } from 'cheerio';
import { FetchError } from 'ofetch';
import { config } from '@/config';
import type { Route } from '@/types';
@@ -195,8 +196,14 @@ async function handler(ctx) {
const data = await cache.tryGet(
resourceUrl,
async () => {
const _r = await ofetch(resourceUrl);
return _r;
try {
return await ofetch(resourceUrl);
} catch (error) {
if (error instanceof FetchError && error.statusCode) {
throw error;
}
return await ofetch(resourceUrl.replace('https://t.me/', 'https://telegram.me/'));
}
},
config.cache.routeExpire,
false