Dropping Email Required: Migrating to Phone-or-Email Authentication

Dropping Email Required: Migrating to Phone-or-Email Authentication Our registration form said "just enter your phone number," but the backend still rejected requests without an email address. A mi...

By · · 1 min read
Dropping Email Required: Migrating to Phone-or-Email Authentication

Source: DEV Community

Dropping Email Required: Migrating to Phone-or-Email Authentication Our registration form said "just enter your phone number," but the backend still rejected requests without an email address. A minor bug, but real users were stuck. Here's how we fixed it. Background Our LINE-integrated e-commerce platform targets users who often lack email addresses or prefer not to provide them. Despite our registration form showing "phone number only," submissions consistently failed with 400 Bad Request errors. The root cause was simple: our frontend sent only phone numbers, but backend validation still enforced email: required. The Solution Frontend Changes (Vue + Vite) Made the email field optional and updated the label accordingly: <input v-model="form.email" type="email" placeholder="Email address (optional)" /> Removed email validation from the client-side submission logic. Backend Changes (Node.js / ts-node) Updated the /api/auth/register endpoint validation: // Before const schema = z.