From c6b677bbdc79b925eaf658e59f47d768b4db5ff7 Mon Sep 17 00:00:00 2001 From: Alma Date: Fri, 11 Apr 2025 11:17:23 +0200 Subject: [PATCH] widget chat 2 --- app/api/rocket-chat/messages/route.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/api/rocket-chat/messages/route.ts b/app/api/rocket-chat/messages/route.ts index 421460a3..286ce1f7 100644 --- a/app/api/rocket-chat/messages/route.ts +++ b/app/api/rocket-chat/messages/route.ts @@ -9,12 +9,13 @@ export async function GET() { return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); } - // Get the user's Rocket.Chat token from their session - const rocketChatToken = session.accessToken; - const rocketChatUserId = session.user.id; + // Use the Rocket.Chat token from environment variables + const rocketChatToken = process.env.ROCKET_CHAT_TOKEN; + const rocketChatUserId = process.env.ROCKET_CHAT_USER_ID; if (!rocketChatToken || !rocketChatUserId) { - return NextResponse.json({ error: "No Rocket.Chat credentials found" }, { status: 401 }); + console.error('Missing Rocket.Chat credentials in environment variables'); + return NextResponse.json({ error: "Server configuration error" }, { status: 500 }); } // Get the user's subscriptions (rooms they are in)