'Firebase Reset Password in Next.js with Typescript not sending email but returning link in console

I am trying to send an email to reset-user-password. When I call the function I get a response back (link as string). But there is no email that was sent (just the link in the console). I have already made sure I was testing a valid email address, as a matter of fact in the Firebase Authentication console there is an option to manually send a reset password email and that does work. I would like to make it clear that I am getting a VALID response link back just no email (not even in spam folder).

Front-end call to firebase auth in backend

export const sendForgotPassword = async(email: string) => {
  const task_forgotPassword = await axios.get(
  `${process.env.NEXT_PUBLIC_API_URL}/member/auth/forgotPassword`,
    {params: {email}}
  );

  if (task_forgotPassword.data) return task_forgotPassword.data as string;
  return null;
}

Backend Call to firebase auth from firebase library

export const forgotPassword = async(req:any, res:any) => {
  const { email } = req.query;

  return await admin
  .auth()
  .generatePasswordResetLink(email)
  .then(async (_link) => {
    console.log(_link, email, email.length);
    res.send(`Sent reset password email to ${email}`);
  })
  .catch((err: FirebaseError) => {
    res.send(err.message);
  })
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source