mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 21:32:10 +03:00
fix(agent-skills): use res.text() for text/markdown endpoint (GAP-1 critical bug)
The /api/agent-skills/[id]/raw endpoint returns text/markdown (plain string), not a JSON envelope. The client was incorrectly calling res.json() and unpacking a non-existent `body` field, causing all preview panes to show empty content. Switch to res.text() and update the test mock to match.
This commit is contained in:
@@ -95,8 +95,8 @@ export function AgentSkillsPageClient(): JSX.Element {
|
||||
try {
|
||||
const res = await fetch(`/api/agent-skills/${id}/raw`);
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||
const json = (await res.json()) as { body: string };
|
||||
setMarkdownCache((prev) => new Map(prev).set(id, json.body ?? ""));
|
||||
const body = await res.text();
|
||||
setMarkdownCache((prev) => new Map(prev).set(id, body));
|
||||
} catch {
|
||||
setMarkdownCache((prev) => {
|
||||
const next = new Map(prev);
|
||||
|
||||
@@ -106,9 +106,9 @@ function mockFetch(skills: AgentSkill[], coverage: SkillCoverage, rawMarkdown =
|
||||
});
|
||||
}
|
||||
if (/\/api\/agent-skills\/.+\/raw/.test(urlStr)) {
|
||||
return new Response(JSON.stringify({ body: rawMarkdown }), {
|
||||
return new Response(rawMarkdown, {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
headers: { "Content-Type": "text/markdown; charset=utf-8" },
|
||||
});
|
||||
}
|
||||
return new Response(JSON.stringify({}), { status: 404 });
|
||||
|
||||
Reference in New Issue
Block a user