From f38c944690d92a5195c084ec3c92aab20cc63294 Mon Sep 17 00:00:00 2001 From: Vadim Sobinin Date: Sun, 15 Mar 2026 00:35:27 +0300 Subject: [PATCH] fix(proxy): use getRequestListener instead of createAdaptorServer createAdaptorServer creates a new HTTP server on each request, which breaks Hono routing. getRequestListener gives a proper request handler for use with an existing server. Co-Authored-By: Claude --- packages/proxy/src/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/proxy/src/index.ts b/packages/proxy/src/index.ts index 833d805..881129b 100644 --- a/packages/proxy/src/index.ts +++ b/packages/proxy/src/index.ts @@ -1,5 +1,5 @@ import { createServer } from 'node:http'; -import { createAdaptorServer } from '@hono/node-server'; +import { getRequestListener } from '@hono/node-server'; import { MachineState, type ServiceConfig } from '@sleepguard/shared'; import { app } from './server/app.js'; import { proxyRequest, proxyWebSocket } from './server/proxy.js'; @@ -15,6 +15,8 @@ function findServiceByHost(host: string | undefined): ServiceConfig | undefined return getServiceManager().findByHost(host); } +const handleRequest = getRequestListener(app.fetch); + // Create the base HTTP server with Hono const server = createServer(async (req, res) => { const service = findServiceByHost(req.headers.host); @@ -31,8 +33,7 @@ const server = createServer(async (req, res) => { } // Otherwise let Hono handle (API, dashboard, waking page) - const honoHandler = createAdaptorServer(app); - honoHandler.emit('request', req, res); + handleRequest(req, res); }); // Handle WebSocket upgrades