From 175ed20a5ffd07a538470fa52d9031480284931c Mon Sep 17 00:00:00 2001 From: 2977094657 <2977094657@qq.com> Date: Tue, 3 Feb 2026 16:31:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(chat):=20proxy=5Fimage=20=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E9=98=B2=E7=9B=97=E9=93=BE=E8=AF=B7=E6=B1=82=E5=A4=B4=E4=BB=A5?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E5=9B=BE=E7=89=87=E5=91=BD=E4=B8=AD=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为部分 CDN 增加更兼容的 User-Agent/Referer/Origin 等兜底策略 --- src/wechat_decrypt_tool/routers/chat_media.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/wechat_decrypt_tool/routers/chat_media.py b/src/wechat_decrypt_tool/routers/chat_media.py index 0943374..d90b224 100644 --- a/src/wechat_decrypt_tool/routers/chat_media.py +++ b/src/wechat_decrypt_tool/routers/chat_media.py @@ -443,6 +443,17 @@ async def proxy_image(url: str): # Different Tencent CDNs enforce different anti-hotlink rules. # Try a couple of safe referers so Moments(qpic) and MP(qpic) both work. header_variants = [ + # WeFlow/Electron uses a MicroMessenger UA + servicewechat.com referer to pass some + # WeChat CDN anti-hotlink checks (qlogo/qpic). Browsers can't set these headers for , + # but our backend proxy can. + { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x63090719) XWEB/8351", + "Accept": "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8", + "Accept-Language": "zh-CN,zh;q=0.9", + "Referer": "https://servicewechat.com/", + "Origin": "https://servicewechat.com", + "Range": "bytes=0-", + }, {"Referer": "https://wx.qq.com/", "Origin": "https://wx.qq.com"}, {"Referer": "https://mp.weixin.qq.com/", "Origin": "https://mp.weixin.qq.com"}, {"Referer": "https://www.baidu.com/", "Origin": "https://www.baidu.com"},