Yes, you can. All you have to do is call the res.end method, optionally pass the status code.
Use one of the following methods:
res.end(); res.status(404).end();
If you want to set the headers as well, you must use the res.set method. See below
res.set('Content-Type', 'text/plain'); res.set({ 'Content-Type': 'text/plain', 'Content-Length': '123', 'ETag': '12345' })
See here http://expressjs.com/api.html for more details.
source share