Open h0medev2024 opened 2 months ago
http-proxy-middleware
const proxyMiddleware = createProxyMiddleware({ target: 'https://xxx.aaa.com', ws:true, secure: false, changeOrigin: true, selfHandleResponse : true, on: { proxyReq: (proxyReq, req, res) => {
// 抓包显示User-Agent未被改变 proxyReq.setHeader('User-Agent', 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'); // 抓包显示User-Agent未被改变 req.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'; console.log('[DEMO] Request header:' + req.rawHeaders); if (req.method == 'POST') { console.log('[DEMO] Request body:' + req.body); } }, proxyRes: responseInterceptor(async (responseBuffer, proxyRes, req, res) => { const response = responseBuffer.toString('utf8'); console.log('[DEMO] Response body:' + response); return responseBuffer; }), error: (err, req, res) => { console.log('[DEMO] Error:' + err.message); },
}, logger: console, });
如代码所示,代理出口抓包显示User-Agent未被改变 Mac 通过npn安装的最新版
Checks
http-proxy-middleware
.Describe the bug (be clear and concise)
const proxyMiddleware = createProxyMiddleware({ target: 'https://xxx.aaa.com', ws:true, secure: false, changeOrigin: true, selfHandleResponse : true, on: { proxyReq: (proxyReq, req, res) => {
}, logger: console, });
如代码所示,代理出口抓包显示User-Agent未被改变 Mac 通过npn安装的最新版