From 7285e45781fce0fe50cfe32c2ec940265afa833d Mon Sep 17 00:00:00 2001 From: Alma Date: Sat, 12 Apr 2025 15:16:13 +0200 Subject: [PATCH] working leantime widget 50 --- app/api/leantime/tasks/route.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/api/leantime/tasks/route.ts b/app/api/leantime/tasks/route.ts index eff2e612..23c425bc 100644 --- a/app/api/leantime/tasks/route.ts +++ b/app/api/leantime/tasks/route.ts @@ -24,12 +24,14 @@ async function getLeantimeUserId(email: string): Promise { console.log('API URL:', process.env.LEANTIME_API_URL); console.log('Token length:', process.env.LEANTIME_TOKEN.length); + const headers: Record = { + 'Content-Type': 'application/json', + 'apiKey': process.env.LEANTIME_TOKEN + }; + const response = await fetch(`${process.env.LEANTIME_API_URL}/api/jsonrpc`, { method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'Authorization': `Bearer ${process.env.LEANTIME_TOKEN}` - }, + headers, body: JSON.stringify({ jsonrpc: '2.0', method: 'leantime.rpc.users.getAll', @@ -96,12 +98,14 @@ export async function GET(request: NextRequest) { } console.log('Fetching tasks for Leantime user ID:', userId); + const headers: Record = { + 'Content-Type': 'application/json', + 'apiKey': process.env.LEANTIME_TOKEN! + }; + const response = await fetch(`${process.env.LEANTIME_API_URL}/api/jsonrpc`, { method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'Authorization': `Bearer ${process.env.LEANTIME_TOKEN}` - }, + headers, body: JSON.stringify({ jsonrpc: '2.0', method: 'leantime.rpc.tickets.getAll',