import { NextRequest, NextResponse } from 'next/server' export async function GET(request: NextRequest) { try { // Extract authorization header from the incoming request const authHeader = request.headers.get('authorization') if (!authHeader) { return NextResponse.json( { error: 'Authorization header required' }, { status: 401 } ) } // Make request to backend Zammad chatbots endpoint const baseUrl = process.env.INTERNAL_API_URL || process.env.NEXT_PUBLIC_API_URL const url = `${baseUrl}/api/v1/zammad/chatbots` const response = await fetch(url, { method: 'GET', headers: { 'Authorization': authHeader, 'Content-Type': 'application/json' } }) const data = await response.json() if (!response.ok) { return NextResponse.json(data, { status: response.status }) } return NextResponse.json(data) } catch (error) { console.error('Error fetching Zammad chatbots:', error) return NextResponse.json( { error: 'Failed to fetch Zammad chatbots' }, { status: 500 } ) } }