From ca287ba9605363cb17af88be800d6eb706b8b969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E8=8B=A5=E9=9C=9C=E5=AF=92?= <912881342@qq.com> Date: Thu, 10 Sep 2020 10:29:36 +0800 Subject: [PATCH] feat: support proxy (#858) --- README.md | 2 ++ lib/common/utils/createRequest.js | 2 ++ lib/common/utils/createRequest.ts | 3 +++ 3 files changed, 7 insertions(+) diff --git a/README.md b/README.md index b7f40c9cc..f50cd97ba 100644 --- a/README.md +++ b/README.md @@ -322,6 +322,8 @@ options: the details you can see [requestPay](https://help.aliyun.com/document_detail/91337.htm) - [useFetch] {Boolean}, default false, it just work in Browser, if true,it means upload object with `fetch` mode ,else `XMLHttpRequest` +- [enableProxy] {Boolean}, Enable proxy request, default is false. +- [proxy] {String | Object}, proxy agent uri or options, default is null. example: diff --git a/lib/common/utils/createRequest.js b/lib/common/utils/createRequest.js index 4ba84df4d..1326a0ece 100644 --- a/lib/common/utils/createRequest.js +++ b/lib/common/utils/createRequest.js @@ -83,6 +83,8 @@ function createRequest(params) { if (this.httpsAgent) { reqParams.httpsAgent = this.httpsAgent; } + reqParams.enableProxy = !!this.options.enableProxy; + reqParams.proxy = this.options.proxy ? this.options.proxy : null; return { url, params: reqParams diff --git a/lib/common/utils/createRequest.ts b/lib/common/utils/createRequest.ts index 85d9bfcb1..412565e82 100644 --- a/lib/common/utils/createRequest.ts +++ b/lib/common/utils/createRequest.ts @@ -102,6 +102,9 @@ export function createRequest(this: any, params) { reqParams.httpsAgent = this.httpsAgent; } + reqParams.enableProxy = !!this.options.enableProxy; + reqParams.proxy = this.options.proxy ? this.options.proxy : null; + return { url, params: reqParams