import { NextResponse } from "next/server"; // Proxy to backend metadata endpoint. Assumes BACKEND_BASE_URL is set. export async function GET() { const { cookies } = await import("next/headers"); const cookieStore = await cookies(); const token = cookieStore.get("auth_token")?.value; const BE_BASE_URL = process.env.BE_BASE_URL || "http://localhost:5000"; if (!token) { return NextResponse.json( { success: false, message: "No token found" }, { status: 401 } ); } const url = `${BE_BASE_URL.replace(/\/$/, "")}/api/v1/metadata`; try { const res = await fetch(url, { method: "GET", headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}`, }, cache: "no-store", }); const data = await res.json(); if (!res.ok) { return NextResponse.json( { success: false, message: data?.message || "Failed to fetch metadata", }, { status: res.status } ); } return NextResponse.json(data); } catch (err) { const message = (err as Error)?.message || "Metadata proxy error"; return NextResponse.json({ success: false, message }, { status: 500 }); } }