From c00963a5332b77a8f66f38a36c42145fa4fdb260 Mon Sep 17 00:00:00 2001 From: Alma Date: Sat, 12 Apr 2025 12:33:26 +0200 Subject: [PATCH] working leantime widget 3 --- app/api/leantime/status-labels/route.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/api/leantime/status-labels/route.ts b/app/api/leantime/status-labels/route.ts index a530e08e..5298a43a 100644 --- a/app/api/leantime/status-labels/route.ts +++ b/app/api/leantime/status-labels/route.ts @@ -18,6 +18,8 @@ export async function GET() { headers: { 'Content-Type': 'application/json', 'X-API-Key': process.env.LEANTIME_TOKEN || '', + 'Accept': 'application/json', + 'Authorization': `Bearer ${session.accessToken}`, }, body: JSON.stringify({ method: 'leantime.rpc.Tickets.Tickets.getAllStatusLabelsByUserId', @@ -30,9 +32,17 @@ export async function GET() { }); const responseText = await response.text(); - console.log('Leantime API Response:', responseText); + console.log('Leantime API Response Status:', response.status); + console.log('Leantime API Response Headers:', response.headers); + console.log('Leantime API Response Body:', responseText); if (!response.ok) { + if (response.status === 401) { + return NextResponse.json({ error: "Unauthorized access to Leantime API" }, { status: 401 }); + } + if (response.status === 403) { + return NextResponse.json({ error: "Forbidden access to Leantime API" }, { status: 403 }); + } throw new Error(`Leantime API returned ${response.status}: ${responseText}`); }