Error code

Node.js ERR_HTTP_HEADERS_SENT

NODE.JSERR_HTTP_HEADERS_SENT
Runtime Error Code· An error code from a programming runtime or package manager, like Node.js or npm.

What it means

An attempt was made to set or send HTTP response headers after the response has already been sent.

How to fix it

  1. Ensure headers are set before calling res.end() or res.json().
  2. Add a return statement after sending a response to stop further execution.
  3. Check for multiple code paths that each try to send a response.

Not affiliated with Node.js. Answer summarized from the manufacturer's manual linked above; consult that source for the authoritative procedure.