Skip to content

Environment Variables

Amit Das edited this page Apr 28, 2026 · 1 revision

🔐 Environment Variables

This page explains all environment variables used by SecureAuth.

Environment variables are required for authentication, encryption, cloud storage, and external service integrations.


📄 Creating Environment File

Create a .env file in the root directory of the project.

Example:

# ===============================================
# SecureAuth Environment Configuration
# ===============================================

APP_NAME="SecureAuth"

APP_URL="http://localhost:3000"

PORT=3000

# ===============================================
# TEXTSNAP CONFIGURATION
# ===============================================

TEXTSNAP_INSTANCE_ID="YOUR_INSTANCE_ID"

TEXTSNAP_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"

# ===============================================
# FIREBASE CONFIGURATION
# ===============================================

FIREBASE_DATABASE_URL="YOUR_FIREBASE_DATABASE_URL"

FIREBASE_DATABASE_SECRET="YOUR_FIREBASE_DATABASE_SECRET"

# ===============================================
# SECURITY CONFIGURATION
# ===============================================

JWT_SECRET="YOUR_SUPER_SECRET_KEY"

ENCRYPTION_KEY="YOUR_ENCRYPTION_KEY"

⚙️ Variable Explanations


APP_NAME

Application display name.

Example:

APP_NAME="SecureAuth"

APP_URL

Public application URL.

Used for:

  • Redirects
  • API callbacks
  • PWA configuration
  • Authentication validation

Example:

APP_URL="https://example.com"

PORT

Port used by the backend server.

Example:

PORT=3000

📲 TextSnap Configuration

SecureAuth uses TextSnap for WhatsApp OTP delivery.


TEXTSNAP_INSTANCE_ID

Your TextSnap instance ID.

Example:

TEXTSNAP_INSTANCE_ID="YOUR_INSTANCE_ID"

TEXTSNAP_ACCESS_TOKEN

Access token for TextSnap API authentication.

Example:

TEXTSNAP_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"

☁️ Firebase Configuration

SecureAuth uses Firebase Realtime Database for secure cloud storage.


FIREBASE_DATABASE_URL

Firebase Realtime Database URL.

Example:

FIREBASE_DATABASE_URL="https://your-project.firebaseio.com/"

FIREBASE_DATABASE_SECRET

Firebase database secret key.

Example:

FIREBASE_DATABASE_SECRET="YOUR_SECRET"

🔒 Security Configuration

These variables are critical for application security.


JWT_SECRET

Used for JWT authentication and session validation.

⚠️ Use a strong random secret.

Example:

JWT_SECRET="super_secure_random_secret"

ENCRYPTION_KEY

Used for encrypting sensitive authenticator data.

⚠️ Must remain private.

Example:

ENCRYPTION_KEY="strong_encryption_key"

🛡️ Security Recommendations

For production environments:

  • Never expose .env publicly
  • Use strong random secrets
  • Rotate credentials regularly
  • Restrict database permissions
  • Store backups securely

⚠️ Important Notes

Changing JWT_SECRET

Changing this will invalidate all active sessions.


Changing ENCRYPTION_KEY

Changing this may make previously encrypted data unreadable.


🚫 Never Commit .env

Add .env to .gitignore

Example:

.env

🔍 Verify Environment Variables

To verify variables are loaded:

printenv

or

cat .env

🛠 Common Issues

Missing Environment Variables

Error example:

Missing required environment variable

Solution:

  • Check .env file exists
  • Verify variable names
  • Restart server after changes

Invalid Firebase URL

Ensure database URL format is correct.

Example:

https://your-project.firebaseio.com/

OTP Not Sending

Check:

  • TextSnap credentials
  • Internet connection
  • API limits

✅ Next Steps

Continue with:


Secure • Fast • Modern ⚡

Clone this wiki locally