Express.js – How to check if headers have already been sent?

Node supports the res.headersSent these days, so you could/should use that. It is a read-only boolean indicating whether the headers have already been sent.

if(res.headersSent) { ... }

See http://nodejs.org/api/http.html#http_response_headerssent

Note: this is the preferred way of doing it, compared to the older Connect ‘headerSent’ property that Niko mentions.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)