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

  1. Cache-bust `locals:content-page:<community>` and `locals:action-ids:<community>`.
  2. Open the content page in a browser, list all `<script>`/asset URLs, and confirm which now carries the server API code.
  3. Update the `.find((assetUrl) => assetUrl.includes('/serverApi-'))` predicate or `extractAssetUrls` to the new naming.
  4. 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

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


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