removed try/catch block. try/catch block used as a logical operator is a anti pattern in JS. In this case, the try/catch was also calling next after response.end() causing errors (attempting to set a header after res.end). Exceptions throw are not HTTP status codes, so when they occur the script fails. Strict equallity is a good practice in JS and should always be used.