Question about Application env

Hi guys!
I would love to ask about Application environments. How can I use them via config/dev.ex file? Or via config/config.ex file? I had created one in that way:

import Config
config :my_app, :key, :value

And then, I tried to get it using Application.get_env(:my_app, :key), and the result was nil.

The only way that worked for me was adding it directly through mix.exs into an application, as an environment - but that way does not satisfy me.
Thanks in advance!!

1 Like

Hello and welcome,

It should be working.

You also need something like this at the end of config/config.exs…

import_config "#{config_env()}.exs"

… if You want to load environment config files (aka dev, prod, test + runtime)

Please show the relevant part of your files.
Versions used also might give a clue (Elixir, Phoenix?!)

1 Like

Hi! The thing I needed was indeed

import_config "#{config_env()}.exs"

Thank you so much!