()
| 11 | export const runtime = "nodejs"; |
| 12 | |
| 13 | export async function GET() { |
| 14 | try { |
| 15 | const res = await fetch(`${kbApiBase()}/api/workspaces`, { cache: "no-store" }); |
| 16 | if (!res.ok) return NextResponse.json({ workspaces: [], current: null }); |
| 17 | const data = (await res.json()) as { workspaces?: unknown; current?: unknown }; |
| 18 | return NextResponse.json({ |
| 19 | workspaces: Array.isArray(data.workspaces) ? data.workspaces : [], |
| 20 | current: typeof data.current === "string" ? data.current : null, |
| 21 | }); |
| 22 | } catch { |
| 23 | // web 没起 / 不可达:返回空列表,选择器自然隐藏,控制台仍可用(落到默认库) |
| 24 | return NextResponse.json({ workspaces: [], current: null }); |
| 25 | } |
| 26 | } |
nothing calls this directly
no test coverage detected