Skip to content

Make DATABASE_URL and CORS origins configurable via environment variables #5

Description

@InnoxCodes

The database URL and the CORS origins are fixed in code, and python-dotenv is listed in requirements.txt but nothing under app/ reads the environment.

  • app/core/database.py: DATABASE_URL = "sqlite:///./expenses.db". This path is relative to the working directory, so the location of the DB file depends on where uvicorn is started. docker-compose.yml works around it with working_dir: /data, which is easy to miss. Starting the API from a different directory quietly creates a second, empty database.
  • app/main.py: the allowed origins are hard-coded as well, so deploying the frontend somewhere new means editing code.

Suggested fix: a small settings module that reads DATABASE_URL and CORS_ORIGINS from the environment, with the current values as defaults (and use python-dotenv or drop it from the requirements). It would also make the PostgreSQL deployment profile from the README's future work a config change rather than a code change.

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

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions