nodejs post 数据到php $_POST["content"]接收不到的问题

今天写了一段代码,要用到ajax调用php的接口,因为是https的,所以ajax不能跨域,于是使用nodejs调用接口,但是传输数据后 $_POST["content"]接收不到post过来的数据,于是不断百度。

经过查询得知

headers: {
"Content-Type": 'application/json',
},
if ($_SERVER["CONTENT_TYPE"] == "application/json") {
$input = file_get_contents('php://input');
$data=json_decode($input,true);
$ShipperCode=$data["ShipperCode"];
$LogisticCode=$data["LogisticCode"];
}
通过这一句$input = file_get_contents('php://input');能够把post过来的json取得,然后自己格式化下就能任意操作了,至于原理,有空再看吧