简体   繁体   中英

how to access env variables in runtime elixir (localhost) windows

I am using Windows machine where i have elixir project. I have env.bat file where all the environment variables are set. While running the elixir project in local, environment variables are not getting retrieved.

I have tried changing env.bat to.env and having runtime.exs but that is for prod

env.bat file set ENABLE_XXX=true
in config.exs config:app, enable: System.get_env("ENABLE_XXX")
in module host = Application.get_env(:app, :enable)
start server mix phx.server

when access the API call it is showing as nil. how to access enviornment variables in runtime on windows?

Use System.get_env("ENABLE_XXX") from the module, or set it up up inconfig/runtime.exs .

with env.bat:

call env.bat   

and

mix phx.server 

did the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM