Skip to content

Commit

Permalink
fix: 修复:在 esm 模式下, https-proxy-agent/socks-proxy-agent 的导入错误问题
Browse files Browse the repository at this point in the history
fix #178
  • Loading branch information
CaoMeiYouRen committed Jun 13, 2024
1 parent 002b818 commit eb68501
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/utils/ajax.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import axios, { AxiosResponse, Method, AxiosRequestHeaders } from 'axios'
import qs from 'qs'
import debug from 'debug'
import { HttpsProxyAgent } from 'https-proxy-agent'
import { SocksProxyAgent } from 'socks-proxy-agent'
import HttpsProxyAgent from 'https-proxy-agent'
import SocksProxyAgent from 'socks-proxy-agent'
import { isHttpURL, isSocksUrl } from './helper'

const Debugger = debug('push:ajax')
Expand Down Expand Up @@ -44,15 +44,15 @@ export async function ajax<T = any>(config: AjaxConfig): Promise<AxiosResponse<T
Debugger('HTTPS_PROXY: %s', process.env.HTTPS_PROXY)
Debugger('SOCKS_PROXY: %s', process.env.SOCKS_PROXY)
if (isHttpURL(proxyUrl)) {
httpAgent = new HttpsProxyAgent(proxyUrl)
httpAgent = HttpsProxyAgent(proxyUrl)
} else if (isSocksUrl(proxyUrl)) {
httpAgent = new SocksProxyAgent(proxyUrl)
httpAgent = SocksProxyAgent(proxyUrl)
} else if (process.env.HTTPS_PROXY) {
httpAgent = new HttpsProxyAgent(process.env.HTTPS_PROXY)
httpAgent = HttpsProxyAgent(process.env.HTTPS_PROXY)
} else if (process.env.HTTP_PROXY) {
httpAgent = new HttpsProxyAgent(process.env.HTTP_PROXY)
httpAgent = HttpsProxyAgent(process.env.HTTP_PROXY)
} else if (process.env.SOCKS_PROXY) {
httpAgent = new SocksProxyAgent(process.env.SOCKS_PROXY)
httpAgent = SocksProxyAgent(process.env.SOCKS_PROXY)
}
}
const response = await axios(url, {
Expand Down

0 comments on commit eb68501

Please sign in to comment.