You are browsing as a guest. Sign up (or log in) to start making projects!

38m logged

OTP UX Fix and SMTP IPv4 Compatibility

Summary This update focused on two main issues in the OTP flow: improving the user experience when the send-code button is pressed, and making the Gmail SMTP fallback more reliable on Railway by forcing IPv4 instead of the blocked IPv6 path.

1) OTP Send Button UX Improvement

Problem

The previous OTP flow allowed users to click the “Send Code” button repeatedly while the backend was still processing the request. This created a poor user experience and could trigger duplicate email sends or repeated requests.

Fix

The frontend button logic was updated so that while the OTP request is in progress:

  • the button is disabled,
  • the text changes to “Sending…”,
  • repeated clicks are prevented,
  • the button returns to “Send Code” after the request finishes,
  • the user receives a clearer success/error message in English.This makes the request flow feel intentional and prevents confusion during slow network conditions.

2) SMTP IPv4 Fix for Railway:

Problem

The app was trying to connect to Gmail SMTP using Railway’s outbound networking stack. Railway was preferring IPv6 resolution for Gmail, which caused outbound connections to fail with unreachable network errors.

Root Cause

The SMTP connection attempted to reach Gmail over IPv6, but the Railway container did not have a working outbound route for that address family. As a result, the backend could not complete the SMTP connection, even though the app code itself was otherwise valid.

Fix

The Nodemailer transport was updated to force IPv4 resolution by setting:
jsfamily: 4
This keeps the existing SMTP host configuration (host: process.env.SMTP_HOST) but forces Node.js to use IPv4 instead of attempting the failing IPv6 route.Additional timeout settings were also added to prevent request hangs:
jsconnectionTimeout: 10000,greetingTimeout: 5000,socketTimeout: 10000,
This ensures that if SMTP is blocked or slow, the backend responds quickly with a clear error instead of leaving the browser hanging with a generic network issue.

Outcome

The OTP flow is now more stable and user-friendly:

  • the button cannot be spam-clicked,
  • users receive better status feedback,
  • the SMTP connection is more resilient in Railway when Gmail is accessed over IPv4.

This patch addresses the UX problem and the deployment-specific SMTP issue without changing the overall app architecture.

0
20

Comments 0

No comments yet. Be the first!