diff --git a/assistant/src/module/assistant/proxy/http-proxy.ts b/assistant/src/module/assistant/proxy/http-proxy.ts index 1669175..747ccf2 100644 --- a/assistant/src/module/assistant/proxy/http-proxy.ts +++ b/assistant/src/module/assistant/proxy/http-proxy.ts @@ -2,7 +2,7 @@ import http from 'node:http'; import https from 'node:https'; import { rewriteCookieDomain } from '../https/cookie-rewrite.ts'; import { ProxyInfo } from './proxy.ts'; -import { pipeProxyReq, pipeIncoming, pipeStream } from './pipe.ts'; +import { pipeProxyReq, pipeProxyRes, pipeStream } from './pipe.ts'; export const defaultApiProxy = [ { path: '/api/router', @@ -105,7 +105,7 @@ export const httpProxy = (req: http.IncomingMessage, res: http.ServerResponse, p res.writeHead(proxyRes.statusCode, responseHeaders); // 将代理响应流写入客户端响应 // proxyRes.pipe(res, { end: true }); - pipeIncoming(proxyRes, res); + pipeProxyRes(proxyRes, res); }); // 处理代理请求的错误事件 proxyReq.on('error', (err) => { diff --git a/assistant/src/module/assistant/proxy/pipe.ts b/assistant/src/module/assistant/proxy/pipe.ts index 89d7011..d52344c 100644 --- a/assistant/src/module/assistant/proxy/pipe.ts +++ b/assistant/src/module/assistant/proxy/pipe.ts @@ -42,7 +42,7 @@ export const pipeStream = (readStream: fs.ReadStream, res: http.ServerResponse) * @param proxyRes 代理服务器的响应对象 * @param res HTTP服务器响应对象 */ -export const pipeIncoming = (proxyRes: http.IncomingMessage, res: http.ServerResponse) => { +export const pipeProxyRes = (proxyRes: http.IncomingMessage, res: http.ServerResponse) => { if (isBun) { // Bun环境下需要手动收集数据并end,因为Bun的pipe机制与Node.js不同 const chunks: Buffer[] = []; @@ -81,8 +81,6 @@ export const pipeIncoming = (proxyRes: http.IncomingMessage, res: http.ServerRes export const pipeProxyReq = async (req: http.IncomingMessage, proxyReq: http.ClientRequest, res: any) => { if (isBun) { try { - const method = req.method?.toUpperCase(); - console.log('Bun pipeProxyReq method', method, req.body); // @ts-ignore const bunRequest = req.bun.request; const contentType = req.headers['content-type'] || '';