| // GET /api/knowledge-bases — proxy to the Phylo backend KB registry. | |
| import { NextResponse } from "next/server"; | |
| import { phyloBackendUrl } from "@/lib/env"; | |
| export const dynamic = "force-dynamic"; | |
| export async function GET() { | |
| try { | |
| const res = await fetch(`${phyloBackendUrl()}/api/knowledge-bases`, { | |
| headers: { Accept: "application/json" }, | |
| cache: "no-store", | |
| }); | |
| if (!res.ok) { | |
| return NextResponse.json( | |
| { knowledgeBases: [], error: "backend_unreachable" }, | |
| { status: 502 }, | |
| ); | |
| } | |
| const data = await res.json(); | |
| return NextResponse.json(data); | |
| } catch { | |
| return NextResponse.json( | |
| { knowledgeBases: [], error: "backend_unreachable" }, | |
| { status: 502 }, | |
| ); | |
| } | |
| } | |