From 53d34d99fbe35fc5ea9d1d85e233f188c78fc17d Mon Sep 17 00:00:00 2001 From: luo <1187536986@qq.com> Date: Mon, 4 Jul 2022 20:03:40 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E5=A4=B1=E8=B4=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http_proxy.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/http_proxy.js b/lib/http_proxy.js index 49b4838..45b71fb 100644 --- a/lib/http_proxy.js +++ b/lib/http_proxy.js @@ -1,6 +1,7 @@ 'use strict'; -const { URL } = require('url'); +const url = require('url'); +const { URL } = url; const FormStream = require('formstream'); const ContentType = require('content-type'); const address = require('address'); @@ -41,9 +42,10 @@ class HttpProxy { }; if (options.withCredentials === undefined) options.withCredentials = this.config.withCredentials; - - let urlObj = new URL(ctx.href); - urlObj.host = host; + let urlParsed = url.parse(ctx.href); + let index = ctx.href.indexOf(urlParsed.host); + const href = `${host}/${ctx.href.slice(index+1+urlParsed.host.length)}`; + let urlObj = new URL(href); if (options.rewrite) { urlObj = options.rewrite(urlObj); From fdfb90bf5727227bbb4fce265724e9674d5d05a3 Mon Sep 17 00:00:00 2001 From: luo <1187536986@qq.com> Date: Mon, 4 Jul 2022 20:10:07 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0pk.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 30bddf6..fb6687e 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,21 @@ { - "name": "@eggjs/http-proxy", - "version": "1.1.0", - "description": "http proxy for egg", + "name": "http-proxy-lo", + "version": "1.0.0", + "description": "[![NPM version][npm-image]][npm-url]\r [![build status][travis-image]][travis-url]\r [![Test coverage][codecov-image]][codecov-url]\r [![David deps][david-image]][david-url]\r [![Known Vulnerabilities][snyk-image]][snyk-url]\r [![npm download][download-image]][download-url]", "eggPlugin": { "name": "httpProxy" }, - "keywords": [ - "egg", - "eggPlugin", - "egg-plugin", - "proxy" - ], + "main": ".autod.conf.js", + "directories": { + "lib": "lib", + "test": "test" + }, "publishConfig": { "access": "public" }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, "dependencies": { "address": "^1.1.2", "content-type": "^1.0.4", @@ -55,9 +57,14 @@ "ci": { "version": "10, 12" }, - "repository": "git@github.com:eggjs/egg-http-proxy.git", - "bugs": "https://github.com/eggjs/egg/issues", - "homepage": "https://github.com/eggjs/egg-http-proxy#readme", - "author": "TZ ", - "license": "MIT" + "repository": { + "type": "git", + "url": "git+https://github.com/llh1187/egg-http-proxy.git" + }, + "author": "lo", + "license": "MIT", + "bugs": { + "url": "https://github.com/llh1187/egg-http-proxy/issues" + }, + "homepage": "https://github.com/llh1187/egg-http-proxy#readme" } From 65a0b89707da14849baaba724dc2fb28807ddf51 Mon Sep 17 00:00:00 2001 From: luo <1187536986@qq.com> Date: Mon, 4 Jul 2022 20:28:03 +0800 Subject: [PATCH 3/4] =?UTF-8?q?pk.json=E5=8F=98=E5=9B=9E=E5=8E=9F=E6=9D=A5?= =?UTF-8?q?=E7=9A=84=E6=A0=B7=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fb6687e..c2ecced 100644 --- a/package.json +++ b/package.json @@ -67,4 +67,4 @@ "url": "https://github.com/llh1187/egg-http-proxy/issues" }, "homepage": "https://github.com/llh1187/egg-http-proxy#readme" -} +} \ No newline at end of file From 2360b55d5019e352aa38db1379c2a1b036b3210a Mon Sep 17 00:00:00 2001 From: luo <1187536986@qq.com> Date: Mon, 4 Jul 2022 20:29:39 +0800 Subject: [PATCH 4/4] change --- package.json | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index c2ecced..7954ce0 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,19 @@ { - "name": "http-proxy-lo", - "version": "1.0.0", - "description": "[![NPM version][npm-image]][npm-url]\r [![build status][travis-image]][travis-url]\r [![Test coverage][codecov-image]][codecov-url]\r [![David deps][david-image]][david-url]\r [![Known Vulnerabilities][snyk-image]][snyk-url]\r [![npm download][download-image]][download-url]", + "name": "@eggjs/http-proxy", + "version": "1.1.0", + "description": "http proxy for egg", "eggPlugin": { "name": "httpProxy" }, - "main": ".autod.conf.js", - "directories": { - "lib": "lib", - "test": "test" - }, + "keywords": [ + "egg", + "eggPlugin", + "egg-plugin", + "proxy" + ], "publishConfig": { "access": "public" }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, "dependencies": { "address": "^1.1.2", "content-type": "^1.0.4", @@ -57,14 +55,9 @@ "ci": { "version": "10, 12" }, - "repository": { - "type": "git", - "url": "git+https://github.com/llh1187/egg-http-proxy.git" - }, - "author": "lo", - "license": "MIT", - "bugs": { - "url": "https://github.com/llh1187/egg-http-proxy/issues" - }, - "homepage": "https://github.com/llh1187/egg-http-proxy#readme" + "repository": "git@github.com:eggjs/egg-http-proxy.git", + "bugs": "https://github.com/eggjs/egg/issues", + "homepage": "https://github.com/eggjs/egg-http-proxy#readme", + "author": "TZ ", + "license": "MIT" } \ No newline at end of file