When you are using Node.js with Express and you’ve received the dreaded error [err_http_headers_sent]: cannot set headers after they are sent to the client where do you even begin with err_http_headers_sent’. This article will explore common causes of this error, such as calling res.writeHead, res.write, or res.redirect.
A problem occurs when servers send out headers after the message has been received by the client. Node JS applications send multiple responses to the same request – eg. calling the request twice instead of a single request with one response res.send headers.