From 1cdac947a881063d632fe7642d63d43ed10d68a7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 27 Apr 2026 16:18:14 +0000 Subject: [PATCH] =?UTF-8?q?fix(hotdocs):=20SSR=20fetch=20=E5=8A=A0=20Invol?= =?UTF-8?q?utionHell-SSR=20UA=20=E8=AE=A9=20CF=20=E6=94=BE=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 故障 首页右侧 "Hot This Week / 本周最热" 一直显示 "暂无数据"。 直接 curl 后端 /analytics/top-docs 是 200 + 5 条数据正常。 根因 其他 SSR fetcher(fetchProfile / events / feed)都带 "InvolutionHell-SSR/1.0 (+https://involutionhell.com)" UA,匹配 CF Custom Rule 跳过 Bot Fight。HotDocsPreview 之前没加 header,Vercel runner 默认 "node" UA 不匹配规则,按 IP 信誉被拦回 403/empty → catch 返 [] → "暂无数据"。 本 PR 跟其他 SSR fetcher 完全对齐,加 accept + user-agent header。 --- app/components/HotDocsPreview.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/components/HotDocsPreview.tsx b/app/components/HotDocsPreview.tsx index 61f6700..b055be8 100644 --- a/app/components/HotDocsPreview.tsx +++ b/app/components/HotDocsPreview.tsx @@ -20,7 +20,17 @@ async function fetchTopDocs(): Promise { try { const res = await fetch( `${backendUrl}/analytics/top-docs?window=7d&limit=5`, - { next: { revalidate: 300 } }, + { + next: { revalidate: 300 }, + // UA 必须带 "InvolutionHell-SSR" token,否则 Cloudflare Bot Fight Mode + // 会按 Vercel runner IP 信誉判定为 bot 拦截(CF Custom Rule 用这个 + // token 识别"自己人"放行)。其他 SSR fetcher(fetchProfile / events / + // feed)都已经带,唯独本组件之前漏了导致首页 "本周最热" 一直空。 + headers: { + accept: "application/json", + "user-agent": "InvolutionHell-SSR/1.0 (+https://involutionhell.com)", + }, + }, ); if (!res.ok) return []; const json = await res.json();