From 77e79982fa979611c092e39ed5340e21c171443d Mon Sep 17 00:00:00 2001 From: Rogee Date: Mon, 28 Sep 2026 11:57:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(gateway):=20douyinpic=20=E5=9B=BE=E7=89=87?= =?UTF-8?q?=20fetch=20=E6=94=B9=20credentials=20omit=E2=80=94=E2=80=94?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B0=81=E9=9D=A2=E7=BC=93=E5=AD=98=E5=85=A8?= =?UTF-8?q?=E9=87=8F=20502?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit douyinpic CDN 恒返回 Access-Control-Allow-Origin:'*',跨站 fetch 带 credentials:'include' 按 CORS 规范必被拒(TypeError Failed to fetch),封面回填全部失败、creator_work_cover 落 0 行。 公共图片不需要 cookies,改 credentials:'omit' 后浏览器内 fetch 200,回填链路恢复。 验证:test_gateway 55 例全绿;实测 anon 浏览器 image fetch 200 image/jpeg;强制同步后 creator_work_cover 落 7/7(该账号全部作品),/works/:id/cover 正常输出 JPEG。 --- browser_gateway/platform/douyin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/browser_gateway/platform/douyin.py b/browser_gateway/platform/douyin.py index 64b2a05..537d428 100644 --- a/browser_gateway/platform/douyin.py +++ b/browser_gateway/platform/douyin.py @@ -1547,7 +1547,9 @@ def fetch_douyin_image(self: object, alias: str, target: str) -> BrowserMediaRes result = cdp.evaluate( f"""(async()=>{{ try {{ - const r=await fetch({json.dumps(target)},{{credentials:'include',redirect:'error'}}); + // douyinpic CDN 返回 Access-Control-Allow-Origin:'*',跨站 fetch 不能带凭据, + // credentials:'include' 会直接 TypeError Failed to fetch;公共图片无需 cookies。 + const r=await fetch({json.dumps(target)},{{credentials:'omit',redirect:'error'}}); if(!r.body)return {{status:r.status,content_type:r.headers.get('content-type')||'',body:'',too_large:false}}; const reader=r.body.getReader(), chunks=[]; let size=0; for(;;){{const item=await reader.read();if(item.done)break;