Retro.ConfigHelper (Retro v2.2.0) View Source
Helpers for config/*.exs
.
Link to this section Summary
Link to this section Functions
Extract host from url.
Parse the url of Phoenix endpoint.
When deploying Phoenix application behind a proxy, it is common to specify the
:url
option of Phoenix endpoint like this:
config :demo_web, DemoWeb.Endpoint,
url: [scheme: "https", host: "example.com", port: 443, path: "/"],
check_origin: ["https://example.com/"],
# ...
As you can see, the config is verbose because :url
and :check_origin
are sharing
the same pieces of data.
In order to remove this kind of verbose, we can write something like:
import Retro.ConfigHelper
base_url = "https://example.com/"
config :demo_web, DemoWeb.Endpoint,
url: parse_phoenix_endpoint_url(base_url),
check_origin: [base_url],
# ...
Much better.