@cryptotaxi247 / kubo / commits / 6305932b4

fix(daemon): webui URL when rpc is catch-all (#10520)

Closes #10515

Marcin Rataj committed Oct 4, 2024 at 00:51 UTC 6305932b4ef5ca816d8a6f94fccc5b601f16701a
1 file changed +10 -2
cmd/ipfs/kubo/daemon.go
+10 -2
@@ -723,10 +723,18 @@ func serveHTTPApi(req *cmds.Request, cctx *oldcmds.Context) (<-chan error, error
723 for _, listener := range listeners {
724 // we might have listened to /tcp/0 - let's see what we are listing on
725 fmt.Printf("RPC API server listening on %s\n", listener.Multiaddr())
726 - // Browsers require TCP.
726 + // Browsers require TCP with explicit host.
727 switch listener.Addr().Network() {
728 case "tcp", "tcp4", "tcp6":
729 - fmt.Printf("WebUI: http://%s/webui\n", listener.Addr())
729 + rpc := listener.Addr().String()
730 + // replace catch-all with explicit localhost URL that works in browsers
731 + // https://github.com/ipfs/kubo/issues/10515
732 + if strings.Contains(rpc, "0.0.0.0:") {
733 + rpc = strings.Replace(rpc, "0.0.0.0:", "127.0.0.1:", 1)
734 + } else if strings.Contains(rpc, "[::]:") {
735 + rpc = strings.Replace(rpc, "[::]:", "[::1]:", 1)
736 + }
737 + fmt.Printf("WebUI: http://%s/webui\n", rpc)
738 }
739 }
740