From 2266ac7ec8e812d42020fbbaf6b28ceeccbf3eb8 Mon Sep 17 00:00:00 2001 From: Tony Date: Tue, 14 Jul 2026 20:37:11 +0800 Subject: [PATCH] fix(route/telegram): workaround t.me issue (#22717) --- lib/routes/telegram/channel.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/routes/telegram/channel.ts b/lib/routes/telegram/channel.ts index 094690c33..c387f3c7b 100644 --- a/lib/routes/telegram/channel.ts +++ b/lib/routes/telegram/channel.ts @@ -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