TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
jigar patel
NA
310
23.9k
It is possible redirect to other page URL in Node JS?
Apr 26 2018 8:33 AM
we are using below code in our application but not Working...
res.redirect('/index.html'); - not working...
give me proper solution.
code :
router.use(function (req, res, next) {
// check header or url parameters or post parameters for token
var token = req.cookies.token;
// decode token
if (token) {
// verifies secret and checks exp
jwt.verify(token, req.app.get('superSecret'), function (err, decoded) {
if (err) {
return res.json({ success: false, message: 'Failed to authenticate token.' });
// res.redirect('/index.html');
} else {
// if everything is good, save to request for use in other routes
console.log("Token matched");
//set coockie
res.cookie('token', token, { maxAge: 900000, httpOnly: true });
decoded = { ignoreExpiration: true };
req.decoded = decoded;
next();
}
});
} else {
console.log("Token not matched")
return res.redirect('./public/index.html');
}
});
Thanks,
Jigar Patel
Reply
Answers (
1
)
New beginner for Node.js
How to install React version 16?