diff --git a/src/Web/autopilot-monitor-web/app/api/download/bootstrapper/route.ts b/src/Web/autopilot-monitor-web/app/api/download/bootstrapper/route.ts new file mode 100644 index 00000000..9e504bfa --- /dev/null +++ b/src/Web/autopilot-monitor-web/app/api/download/bootstrapper/route.ts @@ -0,0 +1,28 @@ +const BOOTSTRAPPER_URL = + "https://autopilotmonitor.blob.core.windows.net/agent/Install-AutopilotMonitor.ps1"; + +export const runtime = "nodejs"; + +export async function GET() { + try { + const upstream = await fetch(BOOTSTRAPPER_URL, { cache: "no-store" }); + if (!upstream.ok || !upstream.body) { + return Response.redirect(BOOTSTRAPPER_URL, 302); + } + + const headers = new Headers(); + headers.set("Content-Type", "application/octet-stream"); + headers.set( + "Content-Disposition", + 'attachment; filename="Install-AutopilotMonitor.ps1"', + ); + headers.set("Cache-Control", "public, max-age=300"); + + return new Response(upstream.body, { + status: 200, + headers, + }); + } catch { + return Response.redirect(BOOTSTRAPPER_URL, 302); + } +} diff --git a/src/Web/autopilot-monitor-web/app/docs/page.tsx b/src/Web/autopilot-monitor-web/app/docs/page.tsx index 8feb50cd..408458e4 100644 --- a/src/Web/autopilot-monitor-web/app/docs/page.tsx +++ b/src/Web/autopilot-monitor-web/app/docs/page.tsx @@ -211,7 +211,7 @@ function SectionAgentSetup() { Download the PowerShell script that installs and configures the Autopilot Monitor agent: