DEV Community

Neutron
Neutron

Posted on

Answer: Error: Can't set headers after they are sent to the client

The res object in Express is a subclass of Node.js's http.ServerResponse (read the http.js source). You are allowed to call res.setHeader(name, value) as often as you want until you call res.writeHead(statusCode). After writeHead, the headers are baked in and you can only call res.write(data), and…

Top comments (0)