0
일부 이전 Node js 코드를 유지하려고합니다. 기업 프록시를 사용하는 https url에 연결하는 데 문제가 있습니다.nodejs를 사용하여 https를 연결하십시오.
아래 코드는 작동하지 않는 것 같습니다. 이 작업을 실행 한 후
var https = require('https');
var options = {
hostname: 'PROXY_IP',
port : PROXY_PORT,
path : 'https://server.ourdomain.com/path/to/secure/api',
rejectUnauthorized : false,
headers: {
'Authorization': 'Basic ' + new Buffer('username:password').toString('base64'),
'Content-Type': 'application/json',
'Host' : 'https://server.ourdomain.com:443'
}
}
var responseChunk = '';
callback = function(response) {
if(response.statusCode !== 200) {
//Error occured. Handle error
}
response.on('data', function (chunk) {
responseChunk += chunk;
});
response.on('end', function() {
// Got complete response. Process and do something
});
}
var get_req = https.request(options, callback);
get_req.on('error', function(e) {
console.log("Error:" + e)
});
get_req.end();
오류가 나는 request
모듈을 사용하여이 작업을 얻을 수 있었다
Error:Error: socket hang up
입니다. 그러나 https
모듈을 사용하지 마십시오.
무엇이 문제입니까? 사용 요청