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)