Phoenix Extra.
Table of Contents
Phoenix
Phoenix LiveView
- Elixir Streams |> Phoenix forms without changesets!
- Tailwind
- A good way to use "Views" with liveview is to put them in
app_web/live/view1.ex
. The view1 could be the homepage for example and inside it goes the html using~H
. Thenrouter.ex
calls the defined module inview1.ex
→ Phoenix LiveView Counter. - Starknet Explorer → The following file of the repo shows the default layout of every view Repo
OpenApi →
- Open API Specifications for Elixir Plug applications
- How to design better APIs. 15 language-agnostic, actionable tips on REST API design
- Swagger integration to Phoenix framework
Counter App Error →
Solution for the following error:
17:08:15.791 [error] Could not check origin for Phoenix.Socket transport.
Origin of the request: http://<public_ip>:4000
This happens when you are attempting a socket connection to
a different host than the one configured in your config/
files. For example, in development the host is configured
to "localhost" but you may be trying to access it from
"127.0.0.1". To fix this issue, you may either:
In config\runtime.exs
, the port:
parameter isn’t needed, the app uses 4000
. And the important part, the host
parameter needs brackets → [host: host]
to work and the PHX_HOST
env variable doesn’t have to be set, so that “0.0.0.0” is truthy and used as host:
#[...]
host = System.get_env("PHX_HOST") || "0.0.0.0"
port = String.to_integer(System.get_env("PORT") || "4000")
config :counter, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
config :counter, CounterWeb.Endpoint,
url: [[host: host], scheme: "http"],
http: [
# Enable IPv6 and bind on all interfaces.
# Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
# See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
ip: {0, 0, 0, 0, 0, 0, 0, 0},
port: port
],
secret_key_base: secret_key_base
#[...]
Now the app can be accessed with localhost:4000
and <public_ip>:4000