Skip to main content

Environment Variables

Complete reference for all environment variables used by the Vertical Template.

Quick Setup

Copy the example file and fill in your values:

cp .env.example .env.local

Required Variables

Authentication (Microsoft Entra ID)

VariableDescriptionExample
ENTRA_TENANT_IDYour Entra tenant GUID12345678-1234-...
ENTRA_TENANT_NAMEYour Entra tenant nameyourcompany.onmicrosoft.com
ENTRA_CLIENT_IDApp registration client IDabcdef12-3456-...
ENTRA_CLIENT_SECRETApp registration secretabc~xyz...
ENTRA_SCOPESOAuth scopesopenid profile email
# .env.local
ENTRA_TENANT_ID=12345678-1234-1234-1234-123456789012
ENTRA_TENANT_NAME=yourcompany.onmicrosoft.com
ENTRA_CLIENT_ID=abcdef12-3456-7890-abcd-ef1234567890
ENTRA_CLIENT_SECRET=abc~YourSecretHere
ENTRA_SCOPES=openid profile email

NextAuth Configuration

VariableDescriptionExample
NEXTAUTH_SECRETJWT signing secretGenerated secret
NEXTAUTH_URLApplication URLhttp://localhost:3000
# Generate a secure secret
openssl rand -base64 32

# .env.local
NEXTAUTH_SECRET=your-generated-secret-here
NEXTAUTH_URL=http://localhost:3000

Optional Variables

Tenant Configuration

VariableDescriptionDefault
TENANT_DEFAULT_IDDefault tenant IDtemplate
WORKFLOW_DEFAULT_IDDefault workflow ID-
TENANT_DEFAULT_ID=my-tenant
WORKFLOW_DEFAULT_ID=default-workflow

API Configuration

VariableDescriptionExample
BASE_URL_PUBLIC_APIBackend API URLhttps://api.example.com
BASE_URL_PUBLIC_API=https://api.example.com

Feature Flags

VariableDescriptionDefault
NEXT_PUBLIC_ENABLE_CHATEnable chat featurefalse
NEXT_PUBLIC_ENABLE_AIEnable AI featuresfalse
NEXT_PUBLIC_ENABLE_CHAT=true
NEXT_PUBLIC_ENABLE_AI=true

Runtime Configuration

Some configuration is delivered at runtime via the /api/eai/config endpoint rather than environment variables. This keeps secrets out of the client bundle.

// RuntimeConfig type
interface RuntimeConfig {
tenants: Record<string, {
tenantId?: string;
workflowId?: string;
}>;
mapboxToken?: string;
}

Access in components:

import { useRuntimeConfig } from '@enterpriseaigroup/client';

function MyComponent() {
const { mapboxToken } = useRuntimeConfig();
// ...
}

Environment-Specific Files

FilePurposeGit
.env.exampleTemplate for developersCommitted
.env.localLocal developmentIgnored
.env.developmentDevelopment overridesOptional
.env.productionProduction valuesIn CI/CD

Variable Naming Conventions

PrefixAvailabilityUse Case
NEXT_PUBLIC_*Client + ServerPublic feature flags
ENTRA_*Server onlyAuthentication
*_SECRETServer onlySensitive values
No prefixServer onlyGeneral config

Entra ID App Registration

To get the authentication variables, you need an Entra ID app registration:

  1. Go to Azure Portal → Entra ID → App registrations
  2. Create a new registration or use existing
  3. Configure:
    • Redirect URI: http://localhost:3000/api/auth/callback/azure-ad
    • Platform: Web
    • API permissions: openid, profile, email
  4. Create a client secret (Certificates & secrets)
  5. Copy values to .env.local

Example Complete .env.local

# Authentication (Microsoft Entra ID)
ENTRA_TENANT_ID=12345678-1234-1234-1234-123456789012
ENTRA_TENANT_NAME=yourcompany.onmicrosoft.com
ENTRA_CLIENT_ID=abcdef12-3456-7890-abcd-ef1234567890
ENTRA_CLIENT_SECRET=abc~YourSecretHere
ENTRA_SCOPES=openid profile email

# NextAuth
NEXTAUTH_SECRET=your-32-character-secret-here
NEXTAUTH_URL=http://localhost:3000

# API
BASE_URL_PUBLIC_API=https://api.example.com

# Tenant
TENANT_DEFAULT_ID=my-tenant
WORKFLOW_DEFAULT_ID=default-workflow

# Features
NEXT_PUBLIC_ENABLE_CHAT=true
NEXT_PUBLIC_ENABLE_AI=false

Troubleshooting

"Invalid client secret"

  • Secrets expire - check expiration date in Azure Portal
  • Ensure no trailing whitespace in .env.local
  • Restart dev server after changes

"Invalid redirect URI"

  • Verify redirect URI matches exactly in Entra registration
  • Include port number: http://localhost:3000/api/auth/callback/azure-ad

Environment variables not loading

  • File must be named .env.local (not .env)
  • Restart the development server
  • Check for syntax errors (no quotes needed)