mirror of
https://github.com/aljazceru/enclava.git
synced 2025-12-19 00:14:24 +01:00
zammad working
This commit is contained in:
41
frontend/src/app/api/v1/zammad/chatbots/route.ts
Normal file
41
frontend/src/app/api/v1/zammad/chatbots/route.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
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 }
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user