The Open Framework for Building Agents
fix(eve): answer HEAD requests on the health endpoint (#315)
Pranay Prakashd83b41837e11
diff --git a/.changeset/eve-health-head.md b/.changeset/eve-health-head.mdnew file mode 100644index 000000000..19a40fc00--- /dev/null+++ b/.changeset/eve-health-head.md@@ -0,0 +1,5 @@+---+"eve": patch+---++eve's health endpoint (`/eve/v1/health`) now responds to `HEAD` requests, not just `GET`, so load balancers and uptime monitors that probe with `HEAD` (UptimeRobot, Kubernetes probes, and others) no longer report a healthy deployment as down.diff --git a/packages/eve/src/internal/nitro/host/configure-nitro-routes.test.ts b/packages/eve/src/internal/nitro/host/configure-nitro-routes.test.tsindex ff3e3b478..0b60b2917 100644--- a/packages/eve/src/internal/nitro/host/configure-nitro-routes.test.ts+++ b/packages/eve/src/internal/nitro/host/configure-nitro-routes.test.ts@@ -157,7 +157,7 @@ describe("configureNitroRoutes", () => {});const healthHandler = nitro.options.handlers.find(- (handler) => handler.route === EVE_HEALTH_ROUTE_PATH,+ (handler) => handler.route === EVE_HEALTH_ROUTE_PATH && handler.method === "GET",);expect(healthHandler?.handler).toBe(`#eve-route-handler/GET ${EVE_HEALTH_ROUTE_PATH}`);@@ -168,6 +168,30 @@ describe("configureNitroRoutes", () => {expect(virtualSource).not.toContain('"G:\\');});+ it("registers the health route for HEAD so load balancers probing with HEAD see 200", async () => {+ const nitro = createNitroStub();++ await configureNitroRoutes(nitro, createPreparedHost(), {+ surface: "app",+ });++ const healthMethods = nitro.options.handlers+ .filter((handler) => handler.route === EVE_HEALTH_ROUTE_PATH)+ .map((handler) => handler.method);+ expect(healthMethods).toContain("GET");+ expect(healthMethods).toContain("HEAD");++ const headHandler = nitro.options.handlers.find(+ (handler) => handler.route === EVE_HEALTH_ROUTE_PATH && handler.method === "HEAD",+ );+ expect(headHandler?.handler).toBe(`#eve-route-handler/HEAD ${EVE_HEALTH_ROUTE_PATH}`);++ const virtualSource = nitro.options.virtual[headHandler?.handler ?? ""];+ expect(virtualSource).toContain(+ 'import handler from "file:///G:/projects/test-eve/node_modules/.pnpm/[email protected]/node_modules/eve/dist/src/internal/nitro/routes/health.js";',+ );+ });+it("registers workflow routes through physical handlers with relative bundle imports", async () => {const root = "/tmp/eve-nitro-routes";const buildDir = `${root}/nitro`;diff --git a/packages/eve/src/internal/nitro/host/configure-nitro-routes.ts b/packages/eve/src/internal/nitro/host/configure-nitro-routes.tsindex 3c9a4f017..4c4a82dcb 100644--- a/packages/eve/src/internal/nitro/host/configure-nitro-routes.ts+++ b/packages/eve/src/internal/nitro/host/configure-nitro-routes.ts@@ -47,7 +47,7 @@ function registerHandler(nitro: Nitro,options: {handlerPath: string;- method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";+ method?: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE";route: string;},): void {@@ -328,11 +328,17 @@ export async function configureNitroRoutes(method: "GET",route: "/",});- registerHandler(nitro, {- handlerPath: resolvePackageSourceFilePath("src/internal/nitro/routes/health.ts"),- method: "GET",- route: EVE_HEALTH_ROUTE_PATH,- });+ // Register health for GET and HEAD: each (method, route) pair is a+ // distinct Nitro handler, so HEAD must be registered explicitly or load+ // balancers and uptime monitors that probe with HEAD get a 404. Nitro+ // runs the handler for HEAD and omits the body, leaving GET unchanged.+ for (const method of ["GET", "HEAD"] as const) {+ registerHandler(nitro, {+ handlerPath: resolvePackageSourceFilePath("src/internal/nitro/routes/health.ts"),+ method,+ route: EVE_HEALTH_ROUTE_PATH,+ });+ }// The agent info endpoint needs `appRoot` baked at build time (used by// the disk-source fallback in dev) and runs request-time auth, so it