Environment Variables
This guide covers all environment variables used across the NorChain ecosystem.
Explorer API
File: apps/explorer-api/.env
# Server Configuration
PORT=3000
NODE_ENV=development
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/norchain
# OR Supabase
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-anon-key
# JWT Authentication
JWT_SECRET=your-secret-key-change-in-production
JWT_EXPIRES_IN=7d
# Redis (Optional)
REDIS_HOST=localhost
REDIS_PORT=6379
# Blockchain RPC
RPC_URL=https://rpc.norchain.org
CHAIN_ID=65001
# CORS
CORS_ORIGIN=http://localhost:3002,http://localhost:3010,http://localhost:3001
# Rate Limiting
RATE_LIMIT_TTL=60
RATE_LIMIT_MAX=100Explorer App
File: apps/explorer/.env.local
# API Configuration
NEXT_PUBLIC_API_URL=http://localhost:3000/api/v1
# GraphQL
NEXT_PUBLIC_GRAPHQL_URL=http://localhost:3000/graphql
# WebSocket
NEXT_PUBLIC_WS_URL=ws://localhost:3000
# Blockchain RPC
NEXT_PUBLIC_RPC_URL=https://rpc.norchain.org
NEXT_PUBLIC_CHAIN_ID=65001Landing Page
File: apps/landing/.env.local
# API Configuration (for network stats)
NEXT_PUBLIC_API_URL=http://localhost:3000/api/v1NEX Exchange
File: apps/nex-exchange/.env.local
# Explorer API
NEXT_PUBLIC_EXPLORER_API_URL=http://localhost:3000
# Blockchain RPC
NEXT_PUBLIC_RPC_URL=https://rpc.norchain.org
NEXT_PUBLIC_CHAIN_ID=65001Environment-Specific Values
Development
# API URLs
NEXT_PUBLIC_API_URL=http://localhost:3000/api/v1
NEXT_PUBLIC_EXPLORER_API_URL=http://localhost:3000
# RPC
NEXT_PUBLIC_RPC_URL=http://localhost:8545Staging
# API URLs
NEXT_PUBLIC_API_URL=https://staging-api.norchain.org/api/v1
NEXT_PUBLIC_EXPLORER_API_URL=https://staging-api.norchain.org
# RPC
NEXT_PUBLIC_RPC_URL=https://staging-rpc.norchain.orgProduction
# API URLs
NEXT_PUBLIC_API_URL=https://api.norchain.org/api/v1
NEXT_PUBLIC_EXPLORER_API_URL=https://api.norchain.org
# RPC
NEXT_PUBLIC_RPC_URL=https://rpc.norchain.orgSecurity Notes
- Never commit
.envfiles to version control - Use strong secrets for
JWT_SECRETin production - Rotate secrets regularly
- Use different secrets for each environment
- Restrict CORS origins in production
Variable Reference
API URLs
| Variable | Purpose | Default |
|---|---|---|
NEXT_PUBLIC_API_URL | Explorer API base URL | http://localhost:3000/api/v1 |
NEXT_PUBLIC_EXPLORER_API_URL | Explorer API URL (no version) | http://localhost:3000 |
Blockchain
| Variable | Purpose | Default |
|---|---|---|
NEXT_PUBLIC_RPC_URL | Blockchain RPC endpoint | https://rpc.norchain.org |
NEXT_PUBLIC_CHAIN_ID | Chain ID | 65001 |
RPC_URL | Server-side RPC URL | https://rpc.norchain.org |
CHAIN_ID | Server-side Chain ID | 65001 |
Database
| Variable | Purpose | Default |
|---|---|---|
DATABASE_URL | PostgreSQL connection string | - |
SUPABASE_URL | Supabase project URL | - |
SUPABASE_KEY | Supabase anon key | - |
Authentication
| Variable | Purpose | Default |
|---|---|---|
JWT_SECRET | JWT signing secret | - |
JWT_EXPIRES_IN | JWT expiration time | 7d |
Cache
| Variable | Purpose | Default |
|---|---|---|
REDIS_HOST | Redis host | localhost |
REDIS_PORT | Redis port | 6379 |
Validation
Each app validates environment variables on startup. Missing required variables will cause the app to fail with clear error messages.
Example Setup Script
#!/bin/bash
# Explorer API
cat > apps/explorer-api/.env << EOF
PORT=3000
NODE_ENV=development
DATABASE_URL=postgresql://user:password@localhost:5432/norchain
JWT_SECRET=$(openssl rand -hex 32)
RPC_URL=https://rpc.norchain.org
CHAIN_ID=65001
EOF
# Explorer App
cat > apps/explorer/.env.local << EOF
NEXT_PUBLIC_API_URL=http://localhost:3000/api/v1
NEXT_PUBLIC_RPC_URL=https://rpc.norchain.org
NEXT_PUBLIC_CHAIN_ID=65001
EOF
# Landing Page
cat > apps/landing/.env.local << EOF
NEXT_PUBLIC_API_URL=http://localhost:3000/api/v1
EOF