{"record":{"id":"b09b5a0b76fa75d6","repo":"DIYgod/RSSHub","slug":"lofter-cookie","errorCode":null,"errorMessage":"Lofter 用户登录后的 Cookie 值","messagePattern":"Lofter 用户登录后的 Cookie 值","errorType":"exception","errorClass":"ConfigNotFoundError","httpStatus":null,"severity":"error","filePath":"lib/routes/lofter/tag.ts","lineNumber":56,"sourceCode":"\n| new  | date | week | month | total |\n| ---- | ---- | ---- | ----- | ----- |\n| 最新 | 日榜 | 周榜 | 月榜  | 总榜  |`,\n};\n\nasync function handler(ctx) {\n    const name = ctx.req.param('name') ?? '摄影';\n    const type = ctx.req.param('type') ?? 'new';\n    const pageSize = 20;\n    const startingIndex = 0;\n\n    const rootUrl = 'https://www.lofter.com';\n    const linkUrl = `${rootUrl}/tag/${name}/${type}`;\n    const apiUrl = `${rootUrl}/dwr/call/plaincall/TagBean.search.dwr`;\n\n    const cookie = config.lofter.cookies;\n    if (cookie === undefined) {\n        throw new ConfigNotFoundError('Lofter 用户登录后的 Cookie 值');\n    }\n\n    const response = await got({\n        method: 'post',\n        url: apiUrl,\n        body: new URLSearchParams({\n            callCount: '1',\n            scriptSessionId: '${scriptSessionId}187',\n            httpSessionId: '',\n            'c0-scriptName': 'TagBean',\n            'c0-methodName': 'search',\n            'c0-id': '0',\n            'c0-param0': `string:${encodeURI(name)}`,\n            'c0-param1': 'number:0',\n            'c0-param2': 'string:',\n            'c0-param3': `string:${type}`,\n            'c0-param4': 'boolean:false',\n            'c0-param5': 'number:0',","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/lofter/tag.ts#L38-L74","documentation":"Thrown by the Lofter tag handler (lib/routes/lofter/tag.ts:56) as a `ConfigNotFoundError` when `config.lofter.cookies` is `undefined`. The Lofter tag search DWR endpoint requires an authenticated session cookie to return results, so the route refuses to run without it.","triggerScenarios":"Deploying RSSHub without `LOFTER_COOKIES` configured; setting it to an empty string; config key misspelled so `config.lofter.cookies` is undefined.","commonSituations":"Fresh install omitting route-specific config; cookie value expired and was cleared; config not reloaded after edit.","solutions":["Set `LOFTER_COOKES=<cookie string>` in the RSSHub environment and restart.","Copy the full `Cookie` header from a logged-in lofter.com browser session.","Confirm the config schema exposes it as `config.lofter.cookies`."],"exampleFix":"// before: env unset\nLOFTER_COOKIES=\n\n// after\nLOFTER_COOKIES=userNames=...; __utmz=...; LOFTER_PERSISTENT=...","handlingStrategy":"validation","validationCode":"function lofterCookiesConfigured(): boolean {\n    return typeof config.lofter?.cookies === 'string' && config.lofter.cookies.length > 0;\n}\nif (!lofterCookiesConfigured()) {\n    throw new Error('Set LOFTER_COOKIES before enabling Lofter tag routes');\n}","typeGuard":"function hasLofterCookies(c: typeof config): c is typeof config & { lofter: { cookies: string } } {\n    return typeof c.lofter?.cookies === 'string' && c.lofter.cookies.length > 0;\n}","tryCatchPattern":"import ConfigNotFoundError from '@/errors/types/config-not-found';\ntry {\n    await fetchLofterTag(name, type);\n} catch (e) {\n    if (e instanceof ConfigNotFoundError && /Cookie/.test(e.message)) {\n        return { disabled: true, reason: 'LOFTER_COOKIES env var not set' };\n    }\n    throw e;\n}","preventionTips":["Set LOFTER_COOKIES at deploy time.","Refresh the cookie when Lofter rotates sessions.","Mark the route `requireConfig: true`."],"tags":["config","missing-secret","session","lofter"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}