I've manage to generate a token and even verify on the Server side. The issue I'm now having is, I can't return the token and redirect or render the page. I can do one or the other but not both! Seems like when one is used it calls an end and doesn't allow the second or it runs into sending header issues(ie header was already sent). Below is the code:
else {
//This res works fine on its own
res.json({
success: true,
message: 'Enjoy your token!',
token: token
});
//This res works fine on its own
res.redirect('/control');
}