I need to redirect users from URLs like /?v=xxx
to the index without parameters while passing these parameters in some other way to actually use them internally (so I just want to remove the parameters from the address).
The first idea I came up with was the usage of custom headers:
app.get('/', function(req, res) {
if (req.query.v !== undefined) {
res.set('Video-ID', req.query.v);
res.redirect('/');
} else {
console.log(req.get('Video-ID'));
res.render('index', {
videoID: req.get('Video-ID')
});
}
});
but it seems that it doesn't work -- console.log(req.get('Video-ID'));
prints undefined
every time.
Is there any way to redirect user while passing arguments internally without using cookies? If I have to use cookies, what is the best way to do it in Express 4 then?