DIYgod/RSSHub · error · ConfigNotFoundError
缺少 Medium 用户 ${user} 登录后的 Cookie 值
Error message
缺少 Medium 用户 ${user} 登录后的 Cookie 值 What it means
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).
Source
Thrown at lib/routes/medium/for-you.ts:39
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: 'Personalized Recommendations - For You',
maintainers: ['ImSingee'],
handler,
description: `::: warning
Personalized recommendations require the cookie value after logging in, so only self-hosting is supported. See the configuration module on the deployment page for details.
:::`,
};
async function handler(ctx) {
const user = ctx.req.param('user');
const cookie = config.medium.cookies[user];
if (cookie === undefined) {
throw new ConfigNotFoundError(`缺少 Medium 用户 ${user} 登录后的 Cookie 值`);
}
const posts = await getWebInlineRecommendedFeedQuery(user, cookie);
ctx.set('json', posts);
if (!posts) {
// login failed
throw new ConfigNotFoundError(`Medium 用户 ${user} 的 Cookie 无效或已过期`);
}
const urls = posts.items.map((data) => data.post.mediumUrl);
const parsedArticles = await Promise.all(urls.map((url) => parseArticle(ctx, url)));
return {
title: `${user} Medium For You`,
link: 'https://medium.com/',
item: parsedArticles,View on GitHub (pinned to bed535e087)
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.
Example fix
// before // .env has no MEDIUM_COOKIES // after MEDIUM_COOKIES=johndoe=uid%3A...%3Bsid%3A...
Defensive patterns
Strategy: validation
Validate before calling
const cookie = config.medium.cookies?.[user];
if (cookie === undefined) {
throw new ConfigNotFoundError(`Set MEDIUM_COOKIES for user ${user}`);
} Type guard
function hasMediumCookie(user: string): boolean {
return typeof config.medium.cookies?.[user] === 'string' && config.medium.cookies[user].length > 0;
} Prevention
- Configure MEDIUM_COOKIES on every self-hosted instance.
- Document the per-user keying scheme.
- Validate config at startup.
When it happens
Trigger: Request to /medium/for-you/:user with no entry for that user in config.medium.cookies — the cookie map lookup returns undefined.
Common situations: 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.
Related errors
- 缺少 Medium 用户 ${user} 登录后的 Cookie 值
- 缺少 Medium 用户 ${user} 登录后的 Cookie 值
- Medium 用户 ${user} 的 Cookie 无效或已过期
- Medium 用户 ${user} 的 Cookie 无效或已过期
- 无权访问 id 为 ${catalogId} 的 List(可能是未设置 Cookie 或 Cookie 已过期)
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/6a256aa7eac52089.
Report an issue: GitHub.