在Meteor应用程序中调用Accounts.createUser Iron-Router端点正在给net :: ERR_EMPTY_RESPONSE

我有一个meteor应用程序,它的客户端js对我的应用程序公开的API(使用Iron-Router实现的服务器端)进行jQuery ajax GET调用。

客户端:

 $.get('email/test@test.com/transaction/?transactionId=12344', function (data) { console.log(data); }); 

服务器端API:

 Router.route('/email/:email/transaction',{where: 'server'}) .get(function(){ let email = this.params.email; let transactionId = this.params.query.transactionId; if(email === undefined) { let response = { "error" : true, "message" : "Email required" }; this.response.setHeader('Content-Type', 'application/json'); this.response.statusCode = 403; this.response.end(JSON.stringify(response)); return; } // Create the user let user = Accounts.findUserByEmail(email); if(user === undefined) { Accounts.createUser({ email: email, password: transactionId, username: email, profile: { "transactionId" : [{transactionId: transactionId, date: moment(new Date())}] } }); this.response.setHeader('Content-Type', 'application/json'); this.response.statusCode = 200; this.response.end(JSON.stringify({"created": true})); } else { this.response.setHeader('Content-Type', 'application/json'); this.response.statusCode = 200; this.response.end(JSON.stringify({"created": false})); } }); 

本地运行 – 在本地主机:3000 – 这个工程太棒了! 端点被调用,帐户被创build,并返回一个200响应代码。

但是 ,当部署到我的托pipe服务器,端点与net::ERR_EMPTY_RESPONSE失败。 通过试错,我发现删除Accounts.createUser(...)代码会使端点正确响应,但是 – 当然没有用户创build。

有谁知道为什么Accounts.createUser(...)会强制端点产生一个空的回应? net::ERR_EMPTY_RESPONSE

它对我来说是非常奇怪的,它在本地工作,但是,如果我只能弄清楚如何让它在我部署的服务器上创build一个用户,我不在乎为什么有差异。