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