diff --git a/src/client.ts b/src/client.ts index de03f78..2b54875 100644 --- a/src/client.ts +++ b/src/client.ts @@ -111,9 +111,7 @@ export function connect(options: TunnelOptions): Tunnel { async function proxy(req: TunnelRequest): Promise { try { const url = `${target}${req.path}` - const hasBody = req.method !== "GET" && req.method !== "HEAD" && req.body - - console.log(`[tunnel] >> ${req.method} ${url}`, { contentType: req.headers["content-type"], bodyLen: req.body?.length, hasBody }) + const hasBody = req.method !== "GET" && req.method !== "HEAD" const response = await fetch(url, { method: req.method, @@ -123,7 +121,6 @@ export function connect(options: TunnelOptions): Tunnel { }) const contentType = response.headers.get("content-type") - console.log(`[tunnel] << ${response.status} ${req.method} ${url}`, { contentType, location: response.headers.get("location") }) const headers: Record = {} response.headers.forEach((value, key) => { headers[key] = value diff --git a/src/server.tsx b/src/server.tsx index 116e86e..f934e82 100644 --- a/src/server.tsx +++ b/src/server.tsx @@ -64,11 +64,9 @@ app.get("/tunnel", c => { return upgradeWebSocket(c, { async onOpen(_event, ws) { connections[name] = { app, ws } - console.log(`connection opened: ${name} -> ${app}`) send(ws, { subdomain: name }) }, onClose: (_event, _ws) => { - console.log("connection closed:", name) delete connections[name] for (const [id, entry] of pending) { if (entry.subdomain === name) { @@ -102,13 +100,15 @@ app.all("*", async c => { return c.text("Bad Gateway", 502) const id = randomID() - const headers = Object.fromEntries(c.req.raw.headers) + const raw = c.req.raw + const headers: Record = {} + raw.headers.forEach((value, key) => { headers[key] = value }) delete headers['host'] delete headers['connection'] delete headers['keep-alive'] delete headers['transfer-encoding'] delete headers['content-length'] - const body = await c.req.text() + const body = await raw.text() const app = connection.app const result = await new Promise((resolve, reject) => { @@ -146,7 +146,6 @@ app.all("*", async c => { }) function send(connection: any, msg: Request | Success) { - console.log("sending", 'id' in msg ? `${msg.id} ${msg.method} ${msg.path}` : `connected: ${msg.subdomain}`) connection.send(JSON.stringify(msg)) }