import { NextRequest, NextResponse } from 'next/server' export async function POST( request: NextRequest, { params }: { params: { pluginId: string } } ) { 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 } ) } const { pluginId } = params // Make request to backend plugins unload endpoint const baseUrl = process.env.INTERNAL_API_URL || `http://enclava-backend:${process.env.BACKEND_INTERNAL_PORT || '8000'}` const url = `${baseUrl}/api/plugins/${pluginId}/unload` const response = await fetch(url, { method: 'POST', 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) { return NextResponse.json( { error: 'Failed to unload plugin' }, { status: 500 } ) } }