Skip to content

Instantly share code, notes, and snippets.

@luccastera
Created May 3, 2011 14:36
Show Gist options
  • Save luccastera/953434 to your computer and use it in GitHub Desktop.
Save luccastera/953434 to your computer and use it in GitHub Desktop.
"Can't set headers after they are sent." example
app.post('/recover_password', function(req, res) {
User.get(req.body.username, function(err,data) {
if (err) {
req.session.error = 'We could not find this user.';
res.redirect('back'); // ERROR THROWN HERE
} else {
var user = new User(data);
user.resetPassword(function(err,data) {
var newUser = new User(data);
newUser.sendPasswordRecoveryEmail();
});
res.redirect('/recover_password_confirmation');
}
});
});
@eflorico
Copy link

How did you solve this? I'm having the exact same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment