teamhide / fastapi-boilerplate

FastAPI boilerplate for real world production
987 stars 156 forks source link

Config file not working? #17

Open JCFontoura opened 1 year ago

JCFontoura commented 1 year ago

Hi. In the main.py file there is an import from core.config import config, which means that get_config() is being executed before os.environ["ENV"] = env from main(), so I always end up with "development" from ENV: str = "development". Am I missing something?

zzzachzzz commented 1 year ago

I noticed the exact same thing. Setting the environment variable via ENV=prod python main.py works, while python main.py --env prod does not, due to the execution order of get_config() that you mentioned, which determines the config based on the environment variable ENV.

r0otx commented 1 year ago

Я заметил то же самое. Установка переменной среды через ENV=prod python main.pyработает, а python main.py --env prodне из-за упомянутого вами порядка выполнения get_config(), который определяет конфигурацию на основе переменной среды ENV.

How fix it?