0

i'm using nodemailer to send a confirmation email on my project, like so:

  var mailOptions = {
      from: "alex@account",
      to: req.body.email,
      subject: "Account Verification Token",
      html: `<p>Hello,<br/> Please verify your account by clicking the link <br/> <a href=http://${req.headers.host}/confirmation/${token}>Click here to verify</a></p>\n`
    };

Im sending an href link which contains req.headers.host which is my node adress localhost:6000, but I wish it to be my react adress localhost:4000, since its going to change later, I wish to have a variable jst like req.headers.host which will contain my react client's adress, is it possible? or I need to set it manually?

J. Murray
  • 1,460
  • 11
  • 19
Alexander
  • 1,288
  • 5
  • 19
  • 38

2 Answers2

0

If the app is not server-side rendered, you can pass the React client's address from the frontend and include it to your request object which you can then retrieve after it gets to the server.

Olalekan
  • 185
  • 1
  • 10
0

I found the answer I can use the variable :

const addr = `req.headers.referer`
Alexander
  • 1,288
  • 5
  • 19
  • 38