elixir - How can I get the "base url" of a Phoenix app? -
when run phoenix app locally, base url requests http://localhost:4000. in production, it's https://example.com/.
i want pass base url along javascript. how can it?
note:
- i don't want check
conn; want set during compilation or boot, not @ request time. - i know can check
application.get_env(:myapp, myapp.endpoint)[:url][:host] %, doesn't include scheme (httporhttps) or port. if have piece several places, can, i'd rather not.
you can use myapp.endpoint.url()
the link 1.3 docs since documents functions generated in app's endpoint callbacks, function available @ least since 1.2 (i haven't checked earlier).
Comments
Post a Comment