import { RequestHandler } from "@sveltejs/kit"; import { getApiEndpoint, ApiEndpoints } from "$lib/config"; export const GET: RequestHandler = async ({ request }) => { const authHeader = request.headers.get("authorization"); let accessToken = null; if (authHeader && authHeader.startsWith("Bearer ")) { accessToken = authHeader.substring("Bearer ".length); } const url = accessToken ? `${getApiEndpoint(ApiEndpoints.PAIR)}?access_token=${accessToken}` : getApiEndpoint(ApiEndpoints.PAIR); try { const response = await fetch(url, { method: "GET", headers: { Authorization: `Bearer ${import.meta.env.VITE_HF_TOKEN}`, "Cache-Control": "no-cache", }, }); if (response.ok) { const result = await response.json(); return new Response(JSON.stringify(result), { status: 200, }); } else { return new Response(JSON.stringify({ error: "Failed to fetch pair." }), { status: response.status, }); } } catch (error) { return new Response(JSON.stringify({ error: "Failed to fetch pair." }), { status: 500, }); } };