I’m trying to make an e-mail verification system using Node.js, Express and EJS.
Currently, when a user registers, the server will generate a link, say
https://www.website.com/verify=foo/
and then sends it to their e-mail address. How do I make it so that the generated link directs to https://www.website.com/verify/
with the context foo
, and then fetch it using a POST method to /verify
, so that I can execute code with the given context?
2
Answers
Clicking a link usually causes a GET request. So in your server code you should listen for
get
Please pay attention your link should in this case contain a
?
and look like this:https://www.website.com/verify/?foo=value
What I understood from your question is you want to send verification link to the user via email, and you want to include that link in the mail.
Here is one possible solution with demo code using nodemailer package.