From 798b58c63d3021fbc0518685b9b28f625f9da429 Mon Sep 17 00:00:00 2001 From: wighawag Date: Sun, 27 Oct 2024 14:07:47 +0000 Subject: [PATCH] proxy pathname othan than / too --- src/server.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/server.ts b/src/server.ts index 8eca420..f67abe1 100644 --- a/src/server.ts +++ b/src/server.ts @@ -81,12 +81,6 @@ export function createServer( const { id, path } = extractPath(url) if (typeof id === 'number') { - if (path === '/') { - const { host, port } = pool.get(id) || (await pool.start(id)) - return proxy.web(request, response, { - target: `http://${host}:${port}`, - }) - } if (path === '/start') { const { host, port } = await pool.start(id) return done(response, 200, { host, port }) @@ -103,6 +97,11 @@ export function createServer( const messages = pool.get(id)?.messages.get() || [] return done(response, 200, messages) } + + const { host, port } = pool.get(id) || (await pool.start(id)) + return proxy.web(request, response, { + target: `http://${host}:${port}/${path}`, + }) } if (path === '/healthcheck') return done(response, 200)