Mix release @constants and application.get_env

hey there,
I have a mix release container, when i do Application.get_env(:logic, :api_key) i have the correct value, but when i do
@headers [KeyId: Application.get_env(:logic, :api_key), “Content-Type”: “application/json”], it says that the KeyID value is nil?

Any suggestions?

Module attributes which use the at-symbol like this are strictly compile-time values and will fully/immediately evaluate any function calls they are written to include as they compile, including Application.get_env. Since you’re not populating that value until run-time, it will indeed be nil.

The solution here will probably involve adding a new function in this module that wraps Application.get_env.


Yes, it works, thank you for the clarification!