export async function GET(request: Request) { const params = new URL(request.url).searchParams; const id = params.get('id'), anlageId = params.get('anlageId'); if (!id || !anlageId) return new Response('Verbindung fehlt', { status: 400 }); try { const response = await fetch('http://localhost:3000/rk2/opcua/' + encodeURIComponent(id) + '/certificate?anlageId=' + encodeURIComponent(anlageId), { cache: 'no-store' }); if (!response.ok) return new Response('Zertifikat konnte nicht geladen werden. Anlage und Verbindung pruefen.', { status: response.status }); return new Response(response.body, { headers: { 'Content-Type': 'application/x-pem-file', 'Content-Disposition': 'attachment; filename="RK-OpcUaClient.pem"', 'Cache-Control': 'no-store' } }); } catch { return new Response('Backend nicht erreichbar', { status: 502 }); } }