{"record":{"id":"6a256aa7eac52089","repo":"DIYgod/RSSHub","slug":"medium-user-cookie-6a256a","errorCode":null,"errorMessage":"缺少 Medium 用户 ${user} 登录后的 Cookie 值","messagePattern":"缺少 Medium 用户 (.+?) 登录后的 Cookie 值","errorType":"exception","errorClass":"ConfigNotFoundError","httpStatus":null,"severity":"error","filePath":"lib/routes/medium/for-you.ts","lineNumber":39,"sourceCode":"        antiCrawler: false,\n        supportBT: false,\n        supportPodcast: false,\n        supportScihub: false,\n    },\n    name: 'Personalized Recommendations - For You',\n    maintainers: ['ImSingee'],\n    handler,\n    description: `::: warning\nPersonalized recommendations require the cookie value after logging in, so only self-hosting is supported. See the configuration module on the deployment page for details.\n:::`,\n};\n\nasync function handler(ctx) {\n    const user = ctx.req.param('user');\n\n    const cookie = config.medium.cookies[user];\n    if (cookie === undefined) {\n        throw new ConfigNotFoundError(`缺少 Medium 用户 ${user} 登录后的 Cookie 值`);\n    }\n\n    const posts = await getWebInlineRecommendedFeedQuery(user, cookie);\n    ctx.set('json', posts);\n\n    if (!posts) {\n        // login failed\n        throw new ConfigNotFoundError(`Medium 用户 ${user} 的 Cookie 无效或已过期`);\n    }\n\n    const urls = posts.items.map((data) => data.post.mediumUrl);\n\n    const parsedArticles = await Promise.all(urls.map((url) => parseArticle(ctx, url)));\n\n    return {\n        title: `${user} Medium For You`,\n        link: 'https://medium.com/',\n        item: parsedArticles,","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/medium/for-you.ts#L21-L57","documentation":"ConfigNotFoundError thrown by the Medium 'for-you' route when config.medium.cookies[user] is undefined. The personalized recommendation feed requires an authenticated session cookie, identical in mechanism to the following route (363).","triggerScenarios":"Request to /medium/for-you/:user with no entry for that user in config.medium.cookies — the cookie map lookup returns undefined.","commonSituations":"Self-hosted RSSHub without MEDIUM_COOKIES configured; cookie key mismatched with the URL user segment; relying on the public instance which never sets user cookies.","solutions":["Set MEDIUM_COOKIES (env) or config.medium.cookies with the key matching the :user segment.","Copy the full Cookie header from an authenticated medium.com browser session.","Restart RSSHub to reload config.","Verify the username key has no leading @ and matches exactly."],"exampleFix":"// before\n// .env has no MEDIUM_COOKIES\n\n// after\nMEDIUM_COOKIES=johndoe=uid%3A...%3Bsid%3A...","handlingStrategy":"validation","validationCode":"const cookie = config.medium.cookies?.[user];\nif (cookie === undefined) {\n    throw new ConfigNotFoundError(`Set MEDIUM_COOKIES for user ${user}`);\n}","typeGuard":"function hasMediumCookie(user: string): boolean {\n    return typeof config.medium.cookies?.[user] === 'string' && config.medium.cookies[user].length > 0;\n}","tryCatchPattern":null,"preventionTips":["Configure MEDIUM_COOKIES on every self-hosted instance.","Document the per-user keying scheme.","Validate config at startup."],"tags":["medium","config","auth","cookie"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}