How to handle email verification in Express and React?

Hi everyone! I am trying to implement email verification after the user's signs-up for the first time, I am using Express and React both in Typescript, this is the code that I wrote to handle it in the better-auth config inside
auth.ts
file server-side:
// Email configuration
  emailVerification: {
    expiresIn: 60 * 60,
    sendOnSignUp: true,
    autoSignInAfterVerification: true,
    sendVerificationEmail: async ({ user, url }) => {
      await sendMail({
        to: user.email, // Changed from user.email
        subject: "Verify Your Account",
        html: `
          <div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
            <h2>Welcome to YNetwork!</h2>
            <p>Hello ${user.name || 'there'},</p> <!-- Changed from user.name, added fallback -->
            <p>Please verify your school email address to complete your registration.</p>
            <p><a href="${url}" style="background-color: #28a745; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px;">Verify Email</a></p>
            <p>This verification is required to ensure only school members can access the platform.</p>
            <hr>
            <p><small>Your School's Social Platform</small></p>
          </div>
        `,
      });
    },
  },

When I click on the button to verify the email, I noticed that it calls an endpoint I don't have in my backend which is: http://localhost:3000/api/auth/verify-email?token=jwt&callbackURL=/
How should I proceed from here on, I am really confused since I really want to keep authentication server side?
Thanks
Was this page helpful?