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

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -