Replace redirect response to use express.js function