【发布时间】:2018-01-16 07:11:14
【问题描述】:
我正在编写一个节点应用程序来向外部 URL 发出 https 请求。我在公司代理后面,我已经设置了
>npm config set proxy http://proxy.sample.example.org:8080
>npm config set https-proxy http://proxy.sample.example.org:8080
我能够毫无问题地下载节点依赖项。但是,当我尝试点击外部 URL 时,它会引发以下错误。
{ Error: getaddrinfo ENOTFOUND example.net example.net:443
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'example.net',
host: 'example.net',
port: 443 }
这同样适用于 google.com。代码如下。
var request = require('request');
request.get(
{
url : connUrl,//This is set to be https://example.net
},function (error, response, body) {
//Print response code
console.log(body);
console.log(error);
});
谁能告诉我哪里出错了
【问题讨论】:
-
因为你的代理没有为节点应用设置。设置代理