Skip to content

Commit

Permalink
feat: 支持通过环境变量(http_proxy等)设置请求代理
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Sep 20, 2022
1 parent 3f85a86 commit d0064cc
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 6 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Expand Up @@ -4,3 +4,4 @@ yarn.lock
pnpm-lock.yaml
lib
dist
*
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -70,8 +70,9 @@
"json5": "^2.1.0",
"node-fetch": "^2",
"ora": "^3.4.0",
"prettier": "^2.2.1",
"prettier": "^2.7.1",
"prompts": "^2.0.4",
"proxy-agent": "^5.0.0",
"signal-exit": "^3.0.3",
"swagger-client": "^3.12.0",
"to-json-schema": "^0.2.5",
Expand Down
2 changes: 2 additions & 0 deletions src/utils.ts
Expand Up @@ -2,6 +2,7 @@ import JSON5 from 'json5'
import nodeFetch from 'node-fetch'
import path from 'path'
import prettier from 'prettier'
import ProxyAgent from 'proxy-agent'
import toJsonSchema from 'to-json-schema'
import {
castArray,
Expand Down Expand Up @@ -649,6 +650,7 @@ export async function httpGet<T>(

const res = await nodeFetch(url, {
method: 'GET',
agent: new ProxyAgent()
})

return res.json()
Expand Down

0 comments on commit d0064cc

Please sign in to comment.