-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration not working with Elixir 1.9 releases #69
Comments
@jfcalvo As far as I know that happens because the place where the config is fetched, the What I usually do is to pass a function that returns the allowed origins, as described in the docs. And in there, I make sure to fetch the config at runtime. # endpoint.ex
plug CORSPlug, origin: &MyCors.my_fun/0
# my_cors.ex
defmodule MyCors do
def my_fun do
Application.fetch_env!(:my_app, :my_allowed_origins)
end
end
# config/releases.exs
config :my_app, my_allowed_origins: System.fetch_env!("MY_CORS_ORIGIN") |
with elixir 1.9 releases you put the dynamic stuff in
https://hexdocs.pm/mix/Mix.Tasks.Release.html#module-runtime-configuration if you imported Mix.Config instead of Config it would reproduce the behavior you're seeing, I'm pretty sure. |
I'm considering this closed for now, please let me know if there is anything I can do on my end and I'll reopen! |
I'm using Elixir 1.9 and configuring the release using the recommended
config/releases.exs
file with the following line:Looks like the previous line is not working as expected and the built release is not allowing requests from the origin set on the
CORS_ORIGIN
env var.I'm doing something wrong? The other configs are working fine so I think this is an specific problem with
cors_plug
.If I define the following line on
prod.exs
the requests works as expected (but of course I lose the possibility of configure the origin executing the release):The text was updated successfully, but these errors were encountered: