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 (http or https) 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

Popular posts from this blog

python - Best design pattern for collection of objects -

go - serving up pdfs using golang -

sharepoint online - C# CSOM SPView ListItemCollection did not update after I add new field in the SP view -