我在NodeChef上运行的Parse Server上使用以下功能:
var sendMail = function(sendMailData) {
return Parse.Cloud.httpRequest({
method: 'POST',
url: 'https://api.sparkpost.com/api/v1/transmissions',
body: {
content: {
from: 'noreply@domain.com',
subject: sendMailData.subject,
template_id: sendMailData.templateId,
},
substitution_data: sendMailData.substitution_data,
recipients: sendMailData.recipients
},
headers: {
'Authorization': 'AUTHKEY',
'Content-Type': 'application/json'
}
});
}
sendMail(defaultSendMailData).then(function(okresp) {
var attemptedSend = false;
if (request.user.get('config')) {
var userConfig = request.user.get('config')
if (userConfig.copyPrescription === true) {
attemptedSend = true;
sendMail(defaultSendMailData).then(function(okresp) {
var attemptedSend = false;
if (request.user.get('config')) {
var userConfig = request.user.get('config')
if (userConfig.copyPrescription === true) {
attemptedSend = true;
sendMail(copyPrescriptionSendMailData).then(function(okresp) {
console.log('Woohoo! You just sent your first mailing 1!');
response.success("Great! Your program has been sent!");
}, function(errresp) {
console.log('Whoops! Something went wrong 1');
console.log(errresp);
response.error(errresp);
});
}
};
console.log('Woohoo! You just sent your first mailing 2!');
if (!attemptedSend) {
response.success("Great! Your program has been sent!");
}
}, function(errresp) {
console.log('Whoops! Something went wrong 2');
console.log(errresp);
response.error(errresp);
});
});
}
});
并收到以下错误:
at Immediate.<anonymous> (/bundle/node_modules/express/lib/router/index.js:618:15)
at Immediate.<anonymous> (/bundle/node_modules/express/lib/application.js:232:9)
at next (/bundle/node_modules/express/lib/router/index.js:271:10)
at Function.process_params (/bundle/node_modules/express/lib/router/index.js:330:12)
at /bundle/node_modules/express/lib/router/index.js:280:7
at trim_prefix (/bundle/node_modules/express/lib/router/index.js:312:13)
at Layer.handle [as handle_request] (/bundle/node_modules/express/lib/router/layer.js:95:5)
at jsonParser (/bundle/node_modules/parse-server/node_modules/body-parser/lib/types/json.js:94:7)
at next (/bundle/node_modules/express/lib/router/index.js:271:10)
at Function.process_params (/bundle/node_modules/express/lib/router/index.js:330:12)
at /bundle/node_modules/express/lib/router/index.js:280:7
at trim_prefix (/bundle/node_modules/express/lib/router/index.js:312:13)
at Layer.handle [as handle_request] (/bundle/node_modules/express/lib/router/layer.js:95:5)
at allowCrossDomain (/bundle/index.js:439:9)
at ServerResponse.header (/bundle/node_modules/express/lib/response.js:719:10)
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:344:11)
Error: Can't set headers after they are sent.
虽然功能似乎有效,但我关注这个错误及其来源。我不相信Parse.com就是这种情况(我使用的是完全相同的代码)。此错误未显示在我的Parse.com日志中。任何有关我的Parse Server生产部署的帮助实际上都是这次(第3次尝试!)将非常感激。
答案 0 :(得分:2)
感谢上述所有评论,试图解决此问题。 Node Chef联系过我,他说:
该错误是由星期六2.2.17解析服务器更新引起的。
其他用户注意到并报告了它,我们不得不回滚 更新。
目前,自动更新已关闭,您可以手动更新 从服务器设置随时更新服务器&gt;运行时设置 在您确信新版本适用于您的应用后。
回滚有效,我现在没有任何错误。