fastapi-boilerplate icon indicating copy to clipboard operation
fastapi-boilerplate copied to clipboard

Config file not working?

Open JCFontoura opened this issue 2 years ago • 2 comments

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?

JCFontoura avatar Jan 28 '23 01:01 JCFontoura

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.

zzzachzzz avatar Mar 24 '23 20:03 zzzachzzz

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

How fix it?

r0otx avatar May 14 '23 12:05 r0otx