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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

android - IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -