Skip to main content

Environment Configuration

This document details all environment variables and configuration settings used in the STO Education Platform.

Environment Variables Overview

The platform uses environment variables for configuration, secrets management, and feature flags. All sensitive data is stored securely and accessed through environment variables.

Frontend Environment Variables

Core Configuration

Purpose: Core backend connection and application URL configuration.

Third-Party Integrations

Purpose: Integration with external services for video, chat, analytics, and media management.

Feature Flags

Purpose: Control feature availability and development tools.

Backend Environment Variables (Supabase)

Database Configuration

Purpose: Database connection configuration for Supabase.

Authentication

Purpose: Authentication and JWT token configuration.

Email Service

Purpose: Email sending configuration using Resend service.

Payment Processing

Purpose: Payment processing with PayMob integration.

Environment File Structure

Development Environment

File: .env.local (not committed to git)

Production Environment

File: Environment variables set in deployment platform (Vercel)

Environment Variable Usage

Frontend Usage

Type Safety

Configuration Management

Environment-Specific Configs

Runtime Configuration

Security Considerations

Sensitive Data Protection

  1. Never Commit Secrets: Environment files with secrets are gitignored
  2. Use VITE_ Prefix: Only variables with VITE_ prefix are exposed to frontend
  3. Server-Side Secrets: Backend secrets are kept server-side only
  4. Environment Validation: Validate required variables at startup

Environment Validation

Deployment Configuration

Vercel Deployment

Environment variables are configured in Vercel dashboard:
  1. Production Variables: Set in Vercel project settings
  2. Preview Variables: Set for preview deployments
  3. Development Variables: Set for local development

Build-Time Variables

Feature Flags

Dynamic Feature Control

Runtime Feature Detection

Environment Setup Guide

Development Setup

  1. Copy Environment Template:
  1. Configure Variables:
    • Update Supabase credentials
    • Set third-party API keys
    • Configure feature flags
  2. Validate Configuration:

Production Setup

  1. Set Environment Variables in deployment platform
  2. Configure Secrets for sensitive data
  3. Test Configuration in staging environment
  4. Deploy with validated configuration

Troubleshooting

Common Issues

  1. Missing Environment Variables:
    • Check .env.local file exists
    • Verify variable names match exactly
    • Ensure VITE_ prefix for frontend variables
  2. Type Errors:
    • Update ImportMetaEnv interface
    • Check variable types in configuration
  3. Build Failures:
    • Validate all required variables are set
    • Check for typos in variable names

Debug Environment