i try to send token use header, (login form to index page use the header)
router.post('/login',async(req,res)=>{
const {error} = logvali(req.body);
if(error) return res.status(400).send(error.details[0].message);
//check if the email exist
const user = await User.findOne({email: req.body.email});
if(!user) return res.status(400).send('Email is Wrong');
//password is correct
const vapass = await bcrypt.compare(req.body.password , user.password);
if(!vapass) return res.status(400).send('Password is Wrong');
const token =jwt.sign({_id: user._id},process.env.TOK);
res.header('authtok',token).redirect('/index');
});
my index file is
app.get('/index',verift, function(req, res, next) {
res.render('index');
});
the page redirect index page ,but the token not send the index page