| import { NextResponse } from "next/server"; | |
| import { phyloBackendUrl } from "@/lib/env"; | |
| export const dynamic = "force-dynamic"; | |
| export async function GET( | |
| _req: Request, | |
| { params }: { params: { source: string; entryId: string[] } }, | |
| ) { | |
| const { source, entryId } = params; | |
| if (!source || !entryId || entryId.length === 0) { | |
| return NextResponse.json({ error: "missing_params" }, { status: 400 }); | |
| } | |
| const entryPath = entryId.map(encodeURIComponent).join("/"); | |
| try { | |
| const res = await fetch( | |
| `${phyloBackendUrl()}/api/datasets/${encodeURIComponent(source)}/${entryPath}`, | |
| { | |
| headers: { Accept: "application/json" }, | |
| cache: "no-store", | |
| }, | |
| ); | |
| if (res.status === 404) { | |
| return NextResponse.json({ error: "not_found" }, { status: 404 }); | |
| } | |
| if (!res.ok) { | |
| const text = await res.text().catch(() => ""); | |
| return NextResponse.json( | |
| { error: "backend_error", detail: text }, | |
| { status: res.status }, | |
| ); | |
| } | |
| const data = await res.json(); | |
| return NextResponse.json(data); | |
| } catch { | |
| return NextResponse.json( | |
| { error: "backend_unreachable" }, | |
| { status: 502 }, | |
| ); | |
| } | |
| } | |