DIYgod/RSSHub · error · ConfigNotFoundError
缺少对应论坛的cookie.
Error message
缺少对应论坛的cookie.
What it means
The Discuz route supports per-forum authentication via cookies stored in config.discuz.cookies, keyed by a cid (cookie ID) parameter. When a cid is provided in the route but no matching cookie is found in the configuration, ConfigNotFoundError is thrown. Without the cookie, the route cannot access forums that require login (to view thread lists, member-only sections, etc.).
Source
Thrown at lib/routes/discuz/discuz.ts:105
link: 'link of subforum, require url encoded',
},
name: '通用子版块',
maintainers: ['junfengP', 'pseudoyu'],
handler,
description: `| Discuz X Series | Discuz 7.x Series |
| --------------- | ----------------- |
| x | 7 |`,
};
async function handler(ctx) {
let link = ctx.req.param('link');
const ver = ctx.req.param('ver') ? ctx.req.param('ver').toUpperCase() : undefined;
const cid = ctx.req.param('cid');
link = link.replace(/:\/\//, ':/').replace(/:\//, '://');
const cookie = cid === undefined ? '' : config.discuz.cookies[cid];
if (cookie === undefined) {
throw new ConfigNotFoundError('缺少对应论坛的cookie.');
}
const header = {
Cookie: cookie,
};
const { response, responseData } = await fetchWithAntiBot(link, header);
// 若没有指定编码,则默认utf-8
const contentType = response.headers['content-type'] || '';
let $ = load(iconv.decode(responseData, 'utf-8'));
const charset = contentType.match(/charset=([^;]*)/)?.[1] ?? $('meta[charset]').attr('charset') ?? $('meta[http-equiv="Content-Type"]').attr('content')?.split('charset=', 2)?.[1];
if (charset?.toLowerCase() !== 'utf-8') {
$ = load(iconv.decode(responseData, charset ?? 'utf-8'));
}
const version = ver ? `DISCUZ! ${ver}` : $('head > meta[name=generator]').attr('content');
View on GitHub (pinned to bed535e087)
Solutions
- Configure the forum cookie by setting the appropriate DISCUZ_COOKIES_* environment variable in RSSHub's config.
- Ensure the cid in the route URL matches the key in config.discuz.cookies.
- If the forum doesn't require login, omit the cid parameter entirely from the route path.
- Obtain a fresh cookie by logging into the forum in a browser and copying the Cookie header value.
Defensive patterns
Strategy: validation
Validate before calling
const cid = ctx.req.param('cid');
const cookie = cid === undefined ? '' : config.discuz?.cookies?.[cid];
if (cookie === undefined) {
const configured = Object.keys(config.discuz?.cookies || {});
throw new ConfigNotFoundError(`Cookie for cid '${cid}' not found. Configured cids: ${configured.join(', ') || 'none'}`);
} Type guard
function hasDiscuzCookie(cfg: any, cid: string): boolean {
return cfg?.discuz?.cookies?.[cid] != null;
} Prevention
- Omit the cid parameter entirely if the forum does not require login.
- Configure forum cookies via DISCUZ_COOKIES_* environment variables.
- Keep cookies fresh — expired cookies will cause authentication failures downstream.
- Use a consistent cid naming convention that matches the config key.
When it happens
Trigger: ctx.req.param('cid') returns a value, but config.discuz.cookies[cid] is undefined. The handler then checks if cookie === undefined (distinct from an empty string, which is valid for no-cookie access when cid is not provided). If the cid does not map to a configured cookie, the error fires.
Common situations: User provides a cid in the route path that was never configured; the environment variable for the cookie was not set or named incorrectly; the cookie expired and was removed from config; typo in the cid parameter.
Related errors
- 缺少对应 loginUid 的 Bilibili 用户登录后的 Cookie 值 <a href="https://do
- 对应 loginUid 的 Bilibili 用户的 Cookie 已过期
- Discord RSS is disabled due to the lack of <a href="https://
- Discord RSS is disabled due to the lack of authorization con
- Discord RSS is disabled due to the lack of authorization con
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/dd67e1c1e8729934.
Report an issue: GitHub.