From 9d32521d639d6e55d8a39f0be6521ed0d141c3ba Mon Sep 17 00:00:00 2001 From: Roy Li Date: Mon, 15 Jun 2020 23:03:45 +0800 Subject: [PATCH] fix: wrong url replacement --- packages/gateway/src/app.controller.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/gateway/src/app.controller.ts b/packages/gateway/src/app.controller.ts index 3959090..2929b25 100644 --- a/packages/gateway/src/app.controller.ts +++ b/packages/gateway/src/app.controller.ts @@ -195,7 +195,9 @@ export class AppController { if (!req.url) { throw new HttpException('BAD REQUEST', HttpStatus.BAD_REQUEST); } else { - req.url = req.url.replace(/^\/proxy\/https:\/(\S)/, '/https://$1').replace(/^\/proxy\/http:\/(\S)/, '/http://$1'); + req.url = req.url + .replace(/^(\/proxy)?\/https:\/{1,2}(.*)/, '/https://$2') + .replace(/^(\/proxy)?\/http:\/{1,2}(.*)/, '/http://$2'); proxy.emit('request', req, res); } }