Skip to content

[CONFIG] Implement Environment Configuration System for API URLs #18

@Lexicoding-systems

Description

@Lexicoding-systems

Priority: HIGH

Severity: Production Blocker
Identified in: Design QA Review (2026-01-10)
Locations: Multiple dashboard files

Description

API base URLs are hardcoded in JavaScript, preventing deployment to different environments without code changes. This blocks production deployment and creates inconsistent behavior between dashboards.

Current State

login.html:276

const API_BASE = 'http://localhost:8000';

dashboard.html:1884

const API_BASE = 'http://localhost:8000';

governance_dashboard.html:783

const API_BASE = '';  // Same origin

Problems

  1. Deployment Blocker: Cannot deploy to staging/production without modifying code
  2. Inconsistent Behavior: Three dashboards use different approaches
  3. Security Risk: HTTP hardcoded instead of HTTPS for production
  4. No Environment Separation: Dev/staging/production all require code changes

Recommended Solution

1. Create Environment Configuration System

Create config.js:

// config.js - Load from environment or defaults
window.LEXECON_CONFIG = {
  API_BASE: window.ENV?.API_BASE || 
            (window.location.hostname === 'localhost' 
              ? 'http://localhost:8000' 
              : `${window.location.protocol}//${window.location.host}/api`),
  ENVIRONMENT: window.ENV?.ENVIRONMENT || 'production'
};

2. Update All Dashboards

Replace hardcoded URLs with:

const API_BASE = window.LEXECON_CONFIG.API_BASE;

3. Environment-Specific Configuration

Development:

<script>
  window.ENV = {
    API_BASE: 'http://localhost:8000',
    ENVIRONMENT: 'development'
  };
</script>
<script src="config.js"></script>

Production:

<script>
  window.ENV = {
    API_BASE: 'https://api.lexecon.app',
    ENVIRONMENT: 'production'
  };
</script>
<script src="config.js"></script>

Implementation Steps

  1. Create config.js with environment configuration system
  2. Update login.html to use config
  3. Update dashboard.html to use config
  4. Update governance_dashboard.html to use config
  5. Update deployment scripts to inject environment-specific config
  6. Test in dev, staging, and production environments
  7. Document configuration in deployment guide

Acceptance Criteria

  • No hardcoded API URLs in any JavaScript files
  • Configuration works in dev, staging, and production
  • HTTPS enforced in production
  • Consistent approach across all dashboards
  • Environment configuration documented

Files to Update

  • Create: /frontend/public/config.js
  • Update: login.html
  • Update: dashboard.html
  • Update: governance_dashboard.html
  • Update: docs/PRODUCTION_DEPLOYMENT.md

Related Documentation

Labels

configuration, high-priority, production-blocker, devops

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions