DIYgod/RSSHub · error · ConfigNotFoundError

缺少 Medium 用户 ${user} 登录后的 Cookie 值

Error message

缺少 Medium 用户 ${user} 登录后的 Cookie 值

What it means

ConfigNotFoundError thrown by the Medium 'following' route when no cookie is configured for the given user in config.medium.cookies[user]. Personalized following feeds require an authenticated Medium session cookie, so self-hosting with a valid login cookie is mandatory.

Source

Thrown at lib/routes/medium/following.ts:39

        antiCrawler: false,
        supportBT: false,
        supportPodcast: false,
        supportScihub: false,
    },
    name: 'Personalized Recommendations - Following',
    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 getFollowingFeedQuery(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 Following`,
        link: 'https://medium.com/?feed=following',
        item: parsedArticles,

View on GitHub (pinned to bed535e087)

Solutions

  1. Set the MEDIUM_COOKIES environment variable or config.medium.cookies entry keyed by the exact Medium username (without @).
  2. After logging into medium.com in a browser, copy the 'sid' / 'cf_obc' cookie values into config.
  3. Restart RSSHub after editing config so the new cookies load.
  4. Confirm the cookie key string matches the :user path segment character-for-character.

Example fix

// config (env)
// before: MEDIUM_COOKIES not set

// after (env)
MEDIUM_COOKIES=johndoe=sid%3A1%2C...
Defensive patterns

Strategy: validation

Validate before calling

const cookie = config.medium.cookies?.[user];
if (!cookie) {
    throw new ConfigNotFoundError(`No Medium cookie for ${user}. Set MEDIUM_COOKIES env var.`);
}

Type guard

function hasMediumCookie(user: string): boolean {
    return Boolean(config.medium.cookies?.[user]);
}

Prevention

When it happens

Trigger: config.medium.cookies[user] is undefined — the user has not added a Cookie entry for this Medium handle in the RSSHub configuration (environment variable MIYOUSHE-like env: MEDIUM_COOKIES or config file).

Common situations: Fresh self-hosted RSSHub install without configuring MEDIUM_COOKIES; typo in the user key (cookies keyed by a different handle than the one in the URL); using the public RSSHub instance which intentionally does not set per-user cookies.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/df002c0ac74ddac8. Report an issue: GitHub.