tanweerdev
Get network address everytime I run mix phx.server
Sometimes I need to share network address of my machine with my colleague which have access to same network(same wifi). and its really useful if he can connect to my machine and perform queries/requests from their machine eg when I run a vue project, it prints:
Compiled successfully in 16911ms 4:55:26 PM
App running at:
- Local: http://localhost:8080/
- Network: http://192.16*.***.**:8080/
and I can share this network address with my colleagues and they can access web app on my machine. I am wondering if I can get this network address in phoenix app. Thanks
Marked As Solved
tanweerdev
This is how I got it working(credit goes to):
{ip_string, 0} = System.cmd "hostname", ["-I"]
network_address = List.first String.split(ip_string)
Also Liked
LostKobrakai
This is the default currently. It’s changed on master on github to localhost only however.
LostKobrakai
Given the phoenix generators were just changed to bind to localhost only (and therefore only to a single interface) I doubt this can make it into phoenix itself. You could however alias phx.server and run a custom mix task after phoenix started doing your own logging.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









