DIYgod/RSSHub · error · ConfigNotFoundError

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

Error message

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

What it means

ConfigNotFoundError thrown by the Medium 'tag' route when config.medium.cookies[user] is undefined. The personalized tag feed requires an authenticated cookie, same mechanism as 363/365.

Source

Thrown at lib/routes/medium/tag.ts:42

        supportScihub: false,
    },
    name: 'Personalized Recommendations - Tag',
    maintainers: ['ImSingee'],
    handler,
    description: `There are many tags, which can be obtained by clicking on a tag from the homepage and looking at the URL. For example, if the URL is \`https://medium.com/?tag=web3\`, then the tag is \`web3\`.

::: 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 tag = ctx.req.param('tag');

    const cookie = config.medium.cookies[user];
    if (cookie === undefined) {
        throw new ConfigNotFoundError(`缺少 Medium 用户 ${user} 登录后的 Cookie 值`);
    }

    const posts = await getWebInlineTopicFeedQuery(user, tag, 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 Tag ${tag}`,
        link: `https://medium.com/?tag=${tag}`,
        item: parsedArticles,

View on GitHub (pinned to bed535e087)

Solutions

  1. Set MEDIUM_COOKIES env var keyed by the exact Medium username.
  2. Copy the full Cookie header from a logged-in medium.com session.
  3. Restart RSSHub to load the new config.
  4. Match the cookie key to the :user path segment exactly (no @).

Example fix

// before
// no MEDIUM_COOKIES in env

// after
MEDIUM_COOKIES=johndoe=sid%3A1%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}`);
}

Type guard

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

Prevention

When it happens

Trigger: Request to /medium/tag/:user/:tag with no cookie entry for that user in config — the lookup config.medium.cookies[user] returns undefined.

Common situations: Self-hosted RSSHub without MEDIUM_COOKIES; cookie key does not match the :user segment; using the public instance.

Related errors


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