diff --git a/app/api/emails/route.ts b/app/api/emails/route.ts index 46a29acd..897a7724 100644 --- a/app/api/emails/route.ts +++ b/app/api/emails/route.ts @@ -19,7 +19,7 @@ export async function GET(req: NextRequest) { ); } - // First, try to get the user's Nextcloud ID using the OIDC token + // First, try to get the user's Nextcloud ID using the Keycloak token const userInfoResponse = await fetch(`${nextcloudUrl}/ocs/v2.php/cloud/user`, { headers: { 'Authorization': `Bearer ${session.accessToken}`, @@ -57,11 +57,11 @@ export async function GET(req: NextRequest) { } // Now try to access the Mail app - const response = await fetch(`${nextcloudUrl}/ocs/v2.php/apps/mail/api/v1/accounts`, { + const response = await fetch(`${nextcloudUrl}/index.php/apps/mail/api/accounts`, { headers: { 'Authorization': `Bearer ${session.accessToken}`, 'Accept': 'application/json', - 'OCS-APIRequest': 'true', + 'Content-Type': 'application/json', }, }); @@ -82,7 +82,8 @@ export async function GET(req: NextRequest) { ); } - // If we get here, the Mail app is available + const accounts = await response.json(); + // For now, return a success response with an empty array // We'll implement the actual message fetching once we confirm the correct endpoint return NextResponse.json([]);