{"record":{"id":"1f6cb82a82fc5e08","repo":"DIYgod/RSSHub","slug":"uid-bilibili-cookie","errorCode":null,"errorMessage":"缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值","messagePattern":"缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值","errorType":"exception","errorClass":"ConfigNotFoundError","httpStatus":503,"severity":"error","filePath":"lib/routes/bilibili/followings-article.ts","lineNumber":44,"sourceCode":"        supportBT: false,\n        supportPodcast: false,\n        supportScihub: false,\n    },\n    name: '用户关注专栏',\n    maintainers: ['woshiluo'],\n    handler,\n    description: `::: warning\n用户动态需要 b 站登录后的 Cookie 值，所以只能自建，详情见部署页面的配置模块。\n:::`,\n};\n\nasync function handler(ctx) {\n    const uid = String(ctx.req.param('uid'));\n    const name = await cache.getUsernameFromUID(uid);\n\n    const cookie = config.bilibili.cookies[uid];\n    if (cookie === undefined) {\n        throw new ConfigNotFoundError('缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值');\n    }\n\n    const response = await got({\n        method: 'get',\n        url: `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${uid}&type=64`,\n        headers: {\n            Referer: `https://space.bilibili.com/${uid}/`,\n            Cookie: cookie,\n        },\n    });\n    if (response.data.code === -6) {\n        throw new ConfigNotFoundError('对应 uid 的 Bilibili 用户的 Cookie 已过期');\n    }\n    const cards = response.data.data.cards;\n\n    const out = await Promise.all(\n        cards.map(async (card) => {\n            const card_data = JSON.parse(card.card);","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/bilibili/followings-article.ts#L26-L62","documentation":"ConfigNotFoundError thrown by RSSHub's bilibili followings-article route when no Cookie is configured for the requested uid. The handler reads config.bilibili.cookies[uid] and if it returns undefined, the route cannot authenticate to Bilibili's dynamic_svr API (which requires a logged-in session to fetch another user's article dynamics, type=64). This is a deployment-configuration error, not a runtime/network error.","triggerScenarios":"Calling the /bilibili/followings/article/:uid route when the RSSHub instance's BILIBILI_COOKIE_* environment variable for that uid has not been set. The lookup config.bilibili.cookies[uid] resolves to undefined because no cookie key matching the route's :uid parameter exists in the cookies map.","commonSituations":"Self-hosted RSSHub where the operator forgot to add the BILIBILI_COOKIE_<uid> env var; using a uid that doesn't match any configured cookie key; cookies map keys are numeric strings and the route param is also stringified but the two don't align; fresh deploy without reading the deployment config docs.","solutions":["Set the environment variable BILIBILI_COOKIE_<uid> (e.g. BILIBILI_COOKIE_123456=...) with a valid logged-in Bilibili cookie string for that account, then restart RSSHub.","Verify the uid in the route URL exactly matches the numeric suffix in the env var name.","Extract the cookie from a logged-in browser session on space.bilibili.com (DevTools > Network > copy Cookie header) and use the full string.","Confirm config.bilibili.cookies is being populated by checking lib/config.ts and your .env file is loaded."],"exampleFix":"// before: no env var set\n// Route: /bilibili/followings/article/123456\n\n// after: in .env or docker env\nBILIBILI_COOKIE_123456=SESSDATA=xxx; bili_jct=xxx; DedeUserID=123456;","handlingStrategy":"validation","validationCode":"// Before calling the route, verify the cookie exists\nconst uid = String(ctx.req.param('uid'));\nconst cookie = config.bilibili.cookies[uid];\nif (cookie === undefined) {\n    // Return a friendly error or redirect to config docs\n    throw new ConfigNotFoundError(\n        `No cookie configured for uid ${uid}. Set BILIBILI_COOKIE_${uid} in your environment.`\n    );\n}","typeGuard":"function hasBilibiliCookie(uid: string): boolean {\n    return typeof config.bilibili.cookies?.[uid] === 'string'\n        && config.bilibili.cookies[uid].includes('SESSDATA');\n}","tryCatchPattern":null,"preventionTips":["Document every BILIBILI_COOKIE_<uid> env var in your deployment checklist.","Use a startup health check that validates config.bilibili.cookies is non-empty.","Name cookie env vars with the exact uid to avoid mismatches."],"tags":["bilibili","config","cookie","authentication","rsshub"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}