|
export const GET = async () => { |
|
const url = `https://dylanebert-3d-arena-backend.hf.space/leaderboard`; |
|
|
|
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 leaderboard." }), { |
|
status: response.status, |
|
}); |
|
} |
|
} catch (error) { |
|
return new Response(JSON.stringify({ error: "Failed to fetch leaderboard." }), { |
|
status: 500, |
|
}); |
|
} |
|
}; |
|
|