I have URL like this : http://localhost:3000/pageName and I am setting my express route like below:
app.get("/:pageName",(req,res)=>{
if (authentication === true) {
res.render(req.param.pageName}
})
Above works fine when it gets http://localhost:3000/demo.
However, when it gets this type of URL : http://localhost:3000/pageName/authToken like:
http://localhost:3000/demo/ubawfei346876jhat78gw8898ig8837yr
Route says cannot get demo/ubawfei346876jhat78gw8898ig8837yr and when I changed above code to this :
app.get("/:pageName/: authToken",(req,res) => {
if(authentication===true{
res.render(req.param.pageName}
)}
Then this type of url works fine :
http://localhost:3000/demo/ubawfei346876jhat78gw8898ig8837yr
But this type of URL : http://localhost:3000/demo is not working anymore
I would like to implement something like this when url is something like this
http://localhost:3000/demo then it should redirect to:
req.params.pageName
And when url looks like this http://localhost:3000/demo/yeieyhsi736hdh then it should varify token if varified redirect to:
req.params.pageName