widget chat 17

This commit is contained in:
Alma 2025-04-11 12:10:47 +02:00
parent 3b6b149d41
commit 45a00938db

View File

@ -34,8 +34,18 @@ export async function GET(request: Request) {
}
try {
// Get the base URL from the environment variable
const baseUrl = process.env.NEXT_PUBLIC_IFRAME_PAROLE_URL?.split('/channel')[0];
if (!baseUrl) {
console.error('Failed to get Rocket.Chat base URL from environment variables');
return new Response(JSON.stringify({ error: 'Server configuration error' }), {
status: 500,
headers: { 'Content-Type': 'application/json' },
});
}
// Get user's subscriptions
const subscriptionsResponse = await fetch(`${process.env.ROCKET_CHAT_URL}/api/v1/subscriptions.get`, {
const subscriptionsResponse = await fetch(`${baseUrl}/api/v1/subscriptions.get`, {
headers: {
'X-Auth-Token': session.rocketChatToken,
'X-User-Id': session.rocketChatUserId,
@ -66,7 +76,7 @@ export async function GET(request: Request) {
const roomId = subscription.t === 'c' ? subscription.name : subscription.rid;
const messagesResponse = await fetch(
`${process.env.ROCKET_CHAT_URL}/api/v1/${endpoint}?roomId=${roomId}`,
`${baseUrl}/api/v1/${endpoint}?roomId=${roomId}`,
{
headers: {
'X-Auth-Token': session.rocketChatToken,