0
nodej를 통해 일부 API 게시물 데이터를 개발 중입니다. 문제가 생겼어. https를 통해 데이터를 게시하면 PHP는 빈 데이터를 처리합니다. 누구든지 알고 있습니까? 감사합니다.nodejs ssl 연결을 통해 빈 데이터 게시
a.js =>
//https unauth disable
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
var http = require('https');
var post_req = null,
post_data = '{ "dataid":"81","userid":"29" }';
var post_options = {
hostname: 'www.domain.com',
port : '443',
path : '/get.php',
method : 'POST',
headers : {
'Content-Type': 'application/json;',
'Content-Length': post_data.length
}
};
debugger;
post_req = http.request(post_options, function (res) {
//console.log('STATUS: ' + res.statusCode);
//console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('Response: ', chunk);
});
});
post_req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
debugger;
post_req.write(JSON.stringify(post_data));
debugger;
post_req.end();
그리고 이것은 PHP 코드 블록이다.
get.php =>
print_r($_POST);