{"record":{"id":"941f5dbd074c5321","repo":"DIYgod/RSSHub","slug":"cookie-941f5d","errorCode":null,"errorMessage":"缺少雪球用户登录后的 Cookie 值","messagePattern":"缺少雪球用户登录后的 Cookie 值","errorType":"exception","errorClass":"ConfigNotFoundError","httpStatus":503,"severity":"error","filePath":"lib/routes/xueqiu/timeline.ts","lineNumber":44,"sourceCode":"    },\n    name: '用户关注时间线',\n    maintainers: ['ErnestDong'],\n    handler,\n    description: `::: warning\n用户关注动态需要登录后的 Cookie 值，所以只能自建，详情见部署页面的配置模块。\n:::\n\n| -1   | -2       | 1             |\n| ---- | -------- | ------------- |\n| 全部 | 关注精选 | 自定义第 1 组 |`,\n};\n\nasync function handler(ctx) {\n    const cookie = config.xueqiu.cookies;\n    const limit = ctx.req.query('limit') || 15;\n    const usergroup_id = ctx.req.param('usergroup_id') ?? -1;\n    if (cookie === undefined) {\n        throw new ConfigNotFoundError('缺少雪球用户登录后的 Cookie 值');\n    }\n    let out: DataItem[] = [];\n    let max_id = -1;\n\n    async function fetchItems() {\n        const data = await fetchNextID(max_id, cookie as string, usergroup_id);\n        const items = await Promise.all(\n            data.home_timeline.map((item) =>\n                cache.tryGet(item.target, async () => {\n                    const retweetedStatus = item.retweeted_status ? `<blockquote>${item.retweeted_status.user.screen_name}:&nbsp;${item.retweeted_status.description}</blockquote>` : '';\n                    const description = item.description + retweetedStatus;\n                    const result = await Promise.resolve({\n                        title: item.title === '' ? item.user.screen_name + (item.retweeted_status ? ' 转发' : '') : item.title,\n                        description: item.text ? item.text + retweetedStatus : description,\n                        pubDate: parseDate(item.created_at),\n                        link: rootUrl + item.target,\n                    });\n                    return result;","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/xueqiu/timeline.ts#L26-L62","documentation":"ConfigNotFoundError thrown by the Xueqiu timeline handler when config.xueqiu.cookies is undefined. The home timeline API requires an authenticated xq_a_token cookie that RSSHub cannot obtain anonymously, so the route hard-fails at startup of the request rather than making doomed API calls. Message is in Chinese: '缺少雪球用户登录后的 Cookie 值' (missing Xueqiu logged-in cookie).","triggerScenarios":"Any request to /xueqiu/timeline/:usergroup_id when the XUEQIU_COOKIES environment variable is not set on the RSSHub instance. The check `if (cookie === undefined)` fires immediately in the handler.","commonSituations":"Self-hosted RSSHub without XUEQIU_COOKIES configured; the route is documented as self-host-only because it needs personal cookies; deploy via Docker without passing the env var.","solutions":["Set XUEQIU_COOKIES in the RSSHub environment to the full Cookie header string copied from a logged-in xueqiu.com browser session (it must include xq_a_token).","Restart RSSHub after setting the env var so config reloads.","If the cookie stops working later (Xueqiu sessions expire), refresh it from the browser and update the env var."],"exampleFix":"// before\nif (cookie === undefined) {\n    throw new ConfigNotFoundError('缺少雪球用户登录后的 Cookie 值');\n}\n\n// after — name the env var explicitly so the operator knows what to set\nif (cookie === undefined) {\n    throw new ConfigNotFoundError('缺少雪球用户登录后的 Cookie 值 (set the XUEQIU_COOKIES environment variable with the Cookie header from a logged-in xueqiu.com session, including xq_a_token)');\n}","handlingStrategy":"validation","validationCode":"import { config } from '@/config';\nfunction requireXueqiuCookie() {\n    const cookie = config.xueqiu.cookies;\n    if (cookie === undefined) {\n        throw new ConfigNotFoundError('Set the XUEQIU_COOKIES env var to the Cookie header from a logged-in xueqiu.com session (must include xq_a_token).');\n    }\n    return cookie as string;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set XUEQIU_COOKIES at deploy time and restart RSSHub.","Copy the entire Cookie header (not just one token) from a logged-in browser session.","Refresh the cookie periodically — Xueqiu sessions expire.","Treat this route as self-host-only; it cannot work on the public instance."],"tags":["xueqiu","config","cookie","auth","finance"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}