Heroku-将带有端口的PHP Curl发送到NodeJS

时间:2018-07-17 16:39:29

标签: php node.js curl heroku port

所以我试图将我的Web应用程序上传到Heroku,现在我很困惑

在curl和nodejs中我还很新,几乎我的所有控制器都具有带有curl的功能,这些功能会将数据发送到nodejs。 我已经读到在heroku中,nodejs将侦听分配的端口(使用此行:process.env.PORT)。

我的问题是,如您在下面看到的(我的本地代码),我将端口设置为8080。现在就像我之前在heroku中所说的那样,他们使用分配的端口,无法为我的nodejs代码获取它,所以我怎么能获取我的PHP代码的端口?

这是我的本地nodejs语法

http.listen(8080, function() {
        var addr = http.address();
        console.log('app listening on ' + addr.address + ':' + addr.port);
    });

这是我的职责之一

public function countchild($tabel)
{
    $raw_data = json_decode(file_get_contents('http://localhost:8080/countchild/' . $tabel));
    echo $raw_data;
    return $raw_data;
}

0 个答案:

没有答案