diff --git a/index.js b/index.js index 224a88e4046b6901d1ccecc2f90664d56fa56423..5d9f9798a6517b0aa6919363a301156cea6f0b29 100644 --- a/index.js +++ b/index.js @@ -50,7 +50,7 @@ let url= "https://h5.hunlihu.com"+proxyUrl; options.headers['Content-Length'] = Buffer.byteLength(encodedData); axios.post(url, encodedData, { headers:options.headers }) .then(response => { - console.log('请求成功,响应数据:', response.data); + console.log('请求成功,响应数据:', req,response.data); resolve(response.data) }).catch((err)=>{ reject(err) @@ -75,7 +75,8 @@ const subdirectoryMappings = { 'h5hunlihu': 'https://h5.hunlihu.com', }; // 创建HTTP服务器 -const server = http.createServer((req, res) => { +const server = http.createServer(async(req, res) => { + if(new RegExp(`^\/shunlihu\/`).test(req.url)){ // proxyRes.headers = @@ -107,7 +108,9 @@ const server = http.createServer((req, res) => { res.setHeader('Access-Control-Allow-Credentials', 'true'); https://h5.hunlihu.com/vashow/ly/door/door/init?0.9173087912286308 if(/\/vashow\/ly\/door\/door\/init/.test(req.url)){ - getProxyInfoData(req, res,req.url.replace(/^\/shunlihu/, '')) + let proxyData = await getProxyInfoData(req, res,req.url.replace(/^\/shunlihu/, '')) + res.writeHead(200, { 'Content-Type': 'text/html;charset=utf-8' }); + res.end(proxyData); }else{ proxy.options.target=subdirectoryMappings.h5hunlihu; req.headers['origin'] = subdirectoryMappings.shunlihu;