Skip to content

BUG: Configuration: Replace hardcoded ports/URLs with environment variables #1134

Description

@VasuS609

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

Impact: Deployment flexibility, port conflicts, configuration management

Problem:
Ports and URLs are hardcoded throughout the codebase, making it impossible to:

  • Run multiple instances on the same machine
  • Deploy to cloud platforms with dynamic ports
  • Easily switch between dev/staging/production environments

Locations:

  • main.py:147 - Backend port 52123
  • main.py:51 - Microservice port 52124
  • settings.py:5 - Microservice URL

Recommended Fix:
Create a config.py with environment variables:

import os

class Config:
    BACKEND_PORT = int(os.getenv('BACKEND_PORT', '52123'))
    MICROSERVICE_PORT = int(os.getenv('MICROSERVICE_PORT', '52124'))
    MICROSERVICE_URL = os.getenv('MICROSERVICE_URL', f'http://localhost:{MICROSERVICE_PORT}')
    BACKEND_HOST = os.getenv('BACKEND_HOST', 'localhost')

Benefits:

  • Deploy anywhere without code changes
  • No port conflicts
  • Easy environment switching (dev/prod)
  • Standard Python best practice

Record

  • I agree to follow this project's Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions