I am basically trying to say, if someone types into the browser, xxx.com/homy
, instead of xxx.com/home
, how do I redirect them to a 404 page? here's my index.js file. I am using node.js
// Direct to View Registrations
router.get('/viewRegistration', auth.ensureAuthenticated, function(req, res, next) {
var adminActive = ""
UtilRole.roleCheck(req, res, 'ADMIN', (response) => {
adminActive = response != undefined ? response : false
const user = JSON.parse(req.session.passport.user)
var query = "SELECT * FROM table WHERE email = '" + user.emailAddress + "'";
ibmdb.open(DBCredentials.getDBCredentials(), function(err, conn) {
if (err) return res.send('sorry, were unable to establish a connection to the database. Please try again later.');
conn.query(query, function(err, rows) {
if (err) {
Response.writeHead(404);
}
for (var i = 0; i < rows.length; i++) {
console.log(rows[i])
}
res.render('viewRegistration', {
page_title: "viewRegistration",
data: rows,
user,
role: adminActive
});
return conn.close(function() {
console.log('closed /viewRegistration');
});
});
});
})
})
module.exports = router;