pub fn fullstack_address_or_localhost() -> SocketAddr
Expand description
Get the full address that the server should listen on.
This is a convenience function that combines the server_ip
and server_port
functions and then
falls back to localhost:8080
if the environment variables are not set.
§Example
ⓘ
async fn launch_axum(app: axum::Router<()>) {
// Read the PORT and ADDR environment variables set by the CLI
let addr = dioxus_cli_config::fullstack_address_or_localhost();
// Bind to the address and serve the application
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}
§Stability
In the future, we might change the address from 127.0.0.1 to 0.0.0.0.