跟请求的 url 也有关系,有些就不会报错,有些偶尔能成功,不过我发现请求其实成功了:
```js
let url = require('url')
let https = require('https')
let HttpsProxyAgent = require('https-proxy-agent')
// HTTP/HTTPS proxy to connect to
let proxy = 'http://127.0.0.1:7070'
console.log('using proxy server %j', proxy)
// HTTPS endpoint for the proxy to connect to
let endpoint = '
https://registry.npmjs.org/coc-omni'console.log('attempting to GET %j', endpoint)
let options = url.parse(endpoint)
// create an instance of the `HttpsProxyAgent` class with the proxy server information
let agent = new HttpsProxyAgent(proxy)
options.agent = agent
https.get(options, function (res) {
console.log('"response" event!', res.headers)
res.pipe(process.stdout)
})
```