Meteor生产应用程序上的HTTP返回错误500,但在localhost上返回200

时间:2015-11-10 17:40:07

标签: http meteor

我从今天开始使用MeteorJs,我正在尝试使用HTTP包来加载外部内容。

这是我的服务器端代码:

if (Meteor.isServer) {
  Meteor.methods({
    makeRequest: function (url) {
      return HTTP.call("GET", url);
    }
  });
}

客户端,我尝试发出2个请求:一个直接来自客户端,另一个来自服务器方法:

var url = "http://www.gutenberg.org/cache/epub/6133/pg6133.txt";

// Make a request from the client
Meteor.http.call("GET", url, function(err, result) { 
  console.log("-- CLIENT SIDE --");
  console.log("err : ", err);
  console.log("result : ", result);
});

// Make a request from server 
Meteor.call('makeRequest', url, function(err, result) {
  console.log("-- SERVER SIDE --");
  console.log("err : ", err);
  console.log("result : ", result);
});

在localhost上,服务器端正常工作。但是在服务器上我得到了:

enter image description here

问题#1:如何轻松调试服务器?

问题2:对于此网址(http://www.gutenberg.org/cache/epub/6133/pg6133.txt),我第一次将服务器调用到新网址(http://www.gutenberg.org/ebooks/6133?msg=welcome_stranger)时会有重定向。这可能是导致错误的原因,但我该如何处理呢?

1 个答案:

答案 0 :(得分:0)

调试服务器端的最佳方法是使用:

meteor logs <site>

相关问题