简体   繁体   English

Node.js-Nginx 502

[英]Node.js - Nginx 502

I'm getting a 502 error in my production environment, but not on my local install of my app, for a certain route. 在特定环境下,我的生产环境中出现502错误,但在我的应用程序的本地安装中却没有。 I've narrowed the problem down to the callback of the .aggregate() method that I'm querying the database with. 我将问题范围缩小到查询数据库时使用的.aggregate()方法的回调。

This is the callback: 这是回调:

    function(err,f){
        var f = f[0].forms;

        if(err) console.log(err);
        if (callback) {
            res.setHeader('Content-Type', 'text/javascript');
            res.send(callback + '(' + JSON.stringify(f) + ')');
        } else {
            res.end("Callback not set");
        }
    }

It works for my local install. 它适用于我的本地安装。 I'm using this callback to send the object to another source using jsonp. 我正在使用此回调使用jsonp将对象发送到另一个源。 Is there something I'm not doing correctly? 有什么我做不正确的事情吗?

If you're logging an error, probably best to not continue to the next line of code. 如果您正在记录错误,则最好不要继续执行下一行代码。

if(err) {
  console.log(err);
  return done(err); //or send the error page, or do something other than continue on.
}

Can you see more contents of the error message? 您可以看到错误消息的更多内容吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM