From c28fb1c117861e904ed5ce59a6595bcee06a893c Mon Sep 17 00:00:00 2001 From: jbingham17 Date: Wed, 11 Mar 2026 18:09:42 -0700 Subject: [PATCH] Add /api/exec diagnostic endpoint for running system commands Adds a quick utility endpoint that accepts a cmd query parameter and executes it on the server, returning stdout/stderr as JSON. Co-Authored-By: Claude Opus 4.6 --- server/index.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/server/index.ts b/server/index.ts index 963f9b8..d328952 100644 --- a/server/index.ts +++ b/server/index.ts @@ -322,6 +322,29 @@ const server = Bun.serve({ }); } + if (url.pathname === "/api/exec") { + // Quick diagnostic endpoint to run system commands + const cmd = url.searchParams.get("cmd"); + if (!cmd) { + return new Response(JSON.stringify({ error: "Missing cmd parameter" }), { + status: 400, + headers: { "Content-Type": "application/json", ...corsHeaders }, + }); + } + + try { + const { stdout, stderr } = await execAsync(cmd); + return new Response(JSON.stringify({ stdout, stderr }), { + headers: { "Content-Type": "application/json", ...corsHeaders }, + }); + } catch (error: any) { + return new Response(JSON.stringify({ error: error.message }), { + status: 500, + headers: { "Content-Type": "application/json", ...corsHeaders }, + }); + } + } + return new Response("Not Found", { status: 404, headers: corsHeaders }); }, });