So I want to create a commenting system for my website, and in order to know the page of the comment (for example, a specific video a user has uploaded), I somehow need to get the url of the page the user is currently on, when they comment (so that I know how to save it in the database).
The route is like this: app.get('/video/:videoId', function(req, res){...})
so a video url would be something like: /video/98ux8987s987f9xc89v3wjgrkgh32
.
I need to get the last part of the url, when the user POSTs the comment. I don't want to send the url along with the comment (in the ajax POST function), because they can change it!
And by the way I don't need the url post url (if I have something like req.url
in the post function, I'll just get the post url: app.post('/comment', function(req, res){console.log(req.url)}
if I do this I'll get /comment
).
Is there a way to do it ?
Thank you very much.