Thanks for a useful post. One question on usage of validateUser method. How do we use that method in lets say any PUT path that validates a user?
Simply calling validateUser(req, res, next) is causing the error Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client in the code below validateUser call that assumes the user is already validated.
I am guessing this is happening because express does not immediate terminates the request processing after the response has been sent to the client.
I think your guess is right. Sometimes it happens if a return statement is skipped somewhere, so the execution continues after the first error encounter
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for a useful post. One question on usage of validateUser method. How do we use that method in lets say any PUT path that validates a user?
Simply calling validateUser(req, res, next) is causing the error Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client in the code below validateUser call that assumes the user is already validated.
I am guessing this is happening because express does not immediate terminates the request processing after the response has been sent to the client.
I think your guess is right. Sometimes it happens if a return statement is skipped somewhere, so the execution continues after the first error encounter