Melody AuthMelody Auth
  • Auth Server Setup
  • Admin Panel Setup
  • Email Provider Setup
  • SMS Provider Setup
  • External Identity Providers

    • Social Sign-In Provider Setup
    • OIDC SSO Setup
    • SAML SSO Setup
  • Main Features

    • Authentication
    • JWT & JWKS
    • Multi-Factor Authentication
    • Role-Based Access Control
    • Policies
    • Organizations
  • Additional Features

    • User Attributes
    • App Banners
    • Organization Groups
    • Impersonation
    • Log Management
  • Customization

    • Auth Server Configuration
    • Branding
    • Localization
  • Frontend SDKs

    • React SDK
    • Angular SDK
    • Vue SDK
    • Web SDK
  • Backend APIs

    • S2S API Setup
    • S2S API Swagger
    • Embedded Auth API Setup
    • Embedded Auth API Swagger
  • Deployment Pipelines
  • Rotate JWT Secret
  • English
  • zh-CN
  • Auth Server Setup
  • Admin Panel Setup
  • Email Provider Setup
  • SMS Provider Setup
  • External Identity Providers

    • Social Sign-In Provider Setup
    • OIDC SSO Setup
    • SAML SSO Setup
  • Main Features

    • Authentication
    • JWT & JWKS
    • Multi-Factor Authentication
    • Role-Based Access Control
    • Policies
    • Organizations
  • Additional Features

    • User Attributes
    • App Banners
    • Organization Groups
    • Impersonation
    • Log Management
  • Customization

    • Auth Server Configuration
    • Branding
    • Localization
  • Frontend SDKs

    • React SDK
    • Angular SDK
    • Vue SDK
    • Web SDK
  • Backend APIs

    • S2S API Setup
    • S2S API Swagger
    • Embedded Auth API Setup
    • Embedded Auth API Swagger
  • Deployment Pipelines
  • Rotate JWT Secret
  • English
  • zh-CN
  • SMS Setup

SMS Setup

Melody Auth supports SMS-based Multi-Factor Authentication. To enable it, you need to configure Twilio as your SMS provider.

Supported SMS Providers

  • Twilio

Environment Variables

Use the table below to configure Twilio as your SMS provider.

Variable NameDescriptionExample Value
ENVIRONMENTDetermines the sms sending behavior"prod" or "dev"
DEV_SMS_RECEIVERPhone number for testing (used when ENVIRONMENT ≠ "prod")."+16471231234"
TWILIO_ACCOUNT_IDYour Twilio account id
TWILIO_AUTH_TOKENYour Twilio auth token
TWILIO_SENDER_NUMBERYour Twilio sender number

Production vs. Development Behavior

  • Production (ENVIRONMENT = "prod")

    • Messages will be sent to the actual user phone number.
    • Use this setting for production deployments.
  • Development (ENVIRONMENT ≠ "prod")

    • All messages will be redirected to the phone number specified in DEV_SMS_RECEIVER.
    • This is useful for testing and development to avoid sending messages to real users.

Cloudflare Remote/Production Configuration

  1. Navigate to the Cloudflare dashboard -> Go to "Workers & Pages"
  2. Select your "melody-auth" worker -> "Settings" -> "Variables"
  3. Add any environment variables that apply to your use case.
  4. Click "Save and deploy" to apply the changes.

Cloudflare Local/Development or Node.js Environment

  1. In your melody-auth/server directory, locate or create a .dev.vars file (you can copy .dev.vars.example if needed).
  2. Update any environment variables that apply to your use case to .dev.vars

SMS MFA Country Code

Default country code for SMS MFA is "+1". You can change it by setting the CountryCode for SmsMfaConfig in server/src/configs/variable.ts.

Last Updated: 4/12/25, 2:24 AM
Contributors: Baozier