DIYgod/RSSHub · error · Error
Unable to locate the current Locals serverApi asset.
Error message
Unable to locate the current Locals serverApi asset.
What it means
Thrown by `resolveActionIds` (lib/routes/locals/feed.ts:267) when none of the asset URLs extracted from the content page contains the `/serverApi-` segment. That asset is fetched and scanned to discover the current feed action id; without it the server-function call cannot be assembled. Indicates Locals renamed/restructured its JS bundle or the page did not list script tags.
Source
Thrown at lib/routes/locals/feed.ts:268
thumb: imageMatch?.[2],
},
},
hashtag: community,
id: Number(idMatch[1]),
title: titleMatch[1],
} satisfies LocalsCommunityInfo;
}
function fetchContentPage(community: string, session: string) {
return cache.tryGet(`locals:content-page:${community}`, () => ofetch(`${rootUrl}/${community}/feed?mode=content`, { headers: getRequestHeaders(session) }));
}
function resolveActionIds(community: string, session: string) {
return cache.tryGet(`locals:action-ids:${community}`, async () => {
const html = await fetchContentPage(community, session);
const serverApiAsset = extractAssetUrls(html).find((assetUrl) => assetUrl.includes('/serverApi-'));
if (!serverApiAsset) {
throw new Error('Unable to locate the current Locals serverApi asset.');
}
const assetContent = await ofetch(new URL(serverApiAsset, rootUrl).href, {
headers: getRequestHeaders(session),
});
const serverId = extractFeedActionId(assetContent);
if (!serverId) {
throw new Error('Unable to discover the current Locals feed action id.');
}
return serverId;
});
}
function getImage(post: LocalsPost) {
return post.photos?.[0]?.sizes?.full?.url || post.photos?.[0]?.sizes?.thumb?.url || post.previews?.[0]?.url || post.previews?.[0]?.first_frame_url || post.videos?.[0]?.preview || post.audios?.[0]?.preview;
}View on GitHub (pinned to bed535e087)
Solutions
- Cache-bust `locals:content-page:<community>` and `locals:action-ids:<community>`.
- Open the content page in a browser, list all `<script>`/asset URLs, and confirm which now carries the server API code.
- Update the `.find((assetUrl) => assetUrl.includes('/serverApi-'))` predicate or `extractAssetUrls` to the new naming.
- Ensure `config.locals.session` is valid so the real page (with manifests) is served.
Example fix
// before
const serverApiAsset = extractAssetUrls(html).find((assetUrl) => assetUrl.includes('/serverApi-'));
// after: accept renamed bundle patterns
const serverApiAsset = extractAssetUrls(html).find((assetUrl) =>
/\/server[-_]?(api|function)/i.test(assetUrl)
); Defensive patterns
Strategy: validation
Validate before calling
function hasServerApiAsset(html: string): boolean {
return /\/serverApi-/i.test(html);
}
// before resolving action ids:
if (!hasServerApiAsset(html)) {
throw new TypeError('Locals page has no serverApi asset; bundle may have changed');
} Type guard
function isServerApiAsset(url: string): boolean {
return /\/server[-_]?api/i.test(url);
} Try / catch
try {
return await resolveActionIds(community, session);
} catch (e) {
if (e instanceof Error && /Unable to locate the current Locals serverApi asset/.test(e.message)) {
await cache.delete('locals:content-page:' + community);
return await resolveActionIds(community, session); // one retry on fresh HTML
}
throw e;
} Prevention
- Cache the content page with a short TTL so bundle renames are picked up quickly.
- Keep a fallback predicate list of known asset-name patterns.
- Alert when the asset predicate stops matching so you catch upstream renames early.
When it happens
Trigger: Locals renames the bundle (e.g. `serverApi-` becomes `server-api.` or is inlined into a vendor chunk); the content page is a gate/error page with no script manifests; `extractAssetUrls` regex misses the new `<script src=...>` or `<link>` format.
Common situations: Build/deploy on locals.com changes chunk names; CDN serves a different HTML to RSSHub's UA; cached stale content page predates the rename.
Related errors
- Unable to discover the current Locals feed action id.
- Unable to decode the Locals server response.
- Unable to resolve the Locals community metadata.
- Unable to access the Locals server function (${response.stat
- Invalid Locals content route option. Supported filters are `
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/99dc7fe2455e91d5.
Report an issue: GitHub.