为什么 nodejs http 请求在访问本地服务的 express 应用程序时不起作用?

Why nodejs http request doesn't work when accessing a local served express app?

我在 8082 上有一个 Express REST API 应用程序 运行。然后我尝试使用请求从我的另一个应用程序调用:

request.post({
    url: 'http://localhost:8082/test',
    method: 'POST',
    json: {
        code: 'Hello'
    }   
}, (err, res, body) => {
    console.log(err)
    console.log(res)
    console.log(body)
})

但我遇到 502 Bad Gateway 错误:

<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.10.1</center>
</body>
</html>

看样子是看Nginx不看expressjs?

如何强制它查看我的 运行 应用程序?

检查您的其他应用程序代码以获得正确的端口,或者如果 nginx 正在侦听该端口,则更改端口。