export async function GET(req: Request) { try { const url = new URL(req.url); const parts = url.pathname.split('/'); const id = parts[parts.length - 1] || ''; if (!id) return new Response(JSON.stringify({ error: 'missing id' }), { status: 400, headers: { 'content-type': 'application/json' } }); const backend = process.env.VITE_BACKEND_API_URL || process.env.VITE_TOKEN_SERVER_URL || process.env.BACKEND_URL || process.env.BACKEND || ''; if (!backend) { return new Response(JSON.stringify({ error: 'BACKEND_URL not configured' }), { status: 500, headers: { 'content-type': 'application/json' } }); } const resp = await fetch(`${backend.replace(/\/$/, '')}/api/session/${encodeURIComponent(id)}`); const text = await resp.text(); const headers = { 'content-type': 'application/json' }; return new Response(text, { status: resp.status, headers }); } catch (err) { console.error('proxy GET /api/session/:id error', err); return new Response(JSON.stringify({ error: 'internal' }), { status: 500, headers: { 'content-type': 'application/json' } }); } }