Skip to content

Commit 1cdac94

Browse files
fix(hotdocs): SSR fetch 加 InvolutionHell-SSR UA 让 CF 放行
故障 首页右侧 "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。
1 parent 6ce8104 commit 1cdac94

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

app/components/HotDocsPreview.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@ async function fetchTopDocs(): Promise<TopDocDto[]> {
2020
try {
2121
const res = await fetch(
2222
`${backendUrl}/analytics/top-docs?window=7d&limit=5`,
23-
{ next: { revalidate: 300 } },
23+
{
24+
next: { revalidate: 300 },
25+
// UA 必须带 "InvolutionHell-SSR" token,否则 Cloudflare Bot Fight Mode
26+
// 会按 Vercel runner IP 信誉判定为 bot 拦截(CF Custom Rule 用这个
27+
// token 识别"自己人"放行)。其他 SSR fetcher(fetchProfile / events /
28+
// feed)都已经带,唯独本组件之前漏了导致首页 "本周最热" 一直空。
29+
headers: {
30+
accept: "application/json",
31+
"user-agent": "InvolutionHell-SSR/1.0 (+https://involutionhell.com)",
32+
},
33+
},
2434
);
2535
if (!res.ok) return [];
2636
const json = await res.json();

0 commit comments

Comments
 (0)