Repository: DioxusLabs/dioxus (language: rust)

Issue:
Serving a web app with `--open` or 'o' opens 10.0.0.32 instead of 127.0.0.1
Serving a web application with `--open` or pressing 'o' opens 10.0.0.32 instead of 127.0.0.1 (ie localhost), which is shown in the terminal. 

To reproduce: 
```
dx serve --example hello_world --platform web --open
```

Localhost is treated as a secure context by browsers, which is required for many web API's. This is how pages might fail. For instance, the fullstack-auth example fails to store secure cookies.

This bug is fairly easily worked around by either copying the address from the terminal or opening `http://127.0.0.1:8080` manually. 


Discussion / hints:

Fix patch:
diff --git a/packages/cli/src/cli/run.rs b/packages/cli/src/cli/run.rs
index b9cd100275..55e254f1af 100644
--- a/packages/cli/src/cli/run.rs
+++ b/packages/cli/src/cli/run.rs
@@ -25,14 +25,16 @@ impl RunArgs {
 
         let devserver_ip = "127.0.0.1:8081".parse().unwrap();
         let fullstack_ip = "127.0.0.1:8080".parse().unwrap();
+        let mut open_address = None;
 
         if self.build_args.platform() == Platform::Web || self.build_args.fullstack {
+            open_address = Some(fullstack_ip);
             tracing::info!("Serving at: {}", fullstack_ip);
         }
 
         let mut runner = crate::serve::AppRunner::start(&krate);
         runner
-            .open(bundle, devserver_ip, Some(fullstack_ip), true)
+            .open(bundle, devserver_ip, open_address, Some(fullstack_ip), true)
             .await?;
 
         // Run the app, but mostly ignore all the other messages
diff --git a/packages/cli/src/serve/handle.rs b/packages/cli/src/serve/handle.rs
index 146538b5ac..5d77f89f93 100644
--- a/packages/cli/src/serve/handle.rs
+++ b/packages/cli/src/serve/handle.rs
@@ -67,6 +67,7 @@ impl AppHandle {
     pub(crate) async fn open(
         &mut self,
         devserver_ip: SocketAddr,
+        open_address: Option<SocketAddr>,
         start_fullstack_on_address: Option<SocketAddr>,
         open_browser: bool,
     ) -> Result<()> {
@@ -139,7 +140,7 @@ impl AppHandle {
             Platform::Web => {
                 // Only the first build we open the web app, after that the user knows it's running
                 if open_browser {
-                    self.open_web(devserver_ip);
+                    self.open_web(open_address.unwrap_or(devserver_ip));
                 }
 
                 None
diff --git a/packages/cli/src/serve/mod.rs b/packages/cli/src/serve/mod.rs
index ea94da8751..0f1661507f 100644
--- a/packages/cli/src/serve/mod.rs
+++ b/packages/cli/src/serve/mod.rs
@@ -166,6 +166,7 @@ pub(crate) async fn serve_all(mut args: ServeArgs) -> Result<()> {
                             .open(
                                 bundle,
                                 devserver.devserver_address(),
+                                devserver.displayed_address(),
                                 devserver.proxied_server_address(),
                                 args.open.unwrap_or(false),
                             )
diff --git a/packages/cli/src/serve/runner.rs b/packages/cli/src/serve/runner.rs
index 597c47753f..8c1ede569e 100644
--- a/packages/cli/src/serve/runner.rs
+++ b/packages/cli/src/serve/runner.rs
@@ -97,6 +97,7 @@ impl AppRunner {
         &mut self,
         app: AppBundle,
         devserver_ip: SocketAddr,
+        open_address: Option<SocketAddr>,
         fullstack_address: Option<SocketAddr>,
         should_open_web: bool,
     ) -> Result<&AppHandle> {
@@ -119,6 +120,7 @@ impl AppRunner {
         handle
             .open(
                 devserver_ip,
+                open_address,
                 fullstack_address,
                 self.builds_opened == 0 && should_open_web,
             )
@@ -137,7 +139,12 @@ impl AppRunner {
         if let Some(runner) = self.running.as_mut() {
             runner.soft_kill().await;
             runner
-                .open(devserver.devserver_address(), fullstack_address, true)
+                .open(
+                    devserver.devserver_address(),
+                    devserver.displayed_address(),
+                    fullstack_address,
+                    true,
+                )
                 .await?;
         }
 


Test patch: