ERR_HTTP_HEADERS_SENT: Cannot set headers after they are sent to the client

That particular error occurs whenever you try to send more than one response to the same request and is usually caused by improper asynchronous code. The code you show in your question does not appear like it would cause that error, but I do see code in a different route here that would cause that … Read more