Fix endpoint URL formatting to handle default port correctly

This commit is contained in:
Max 2024-11-29 20:50:24 +08:00
parent 6b6edab97c
commit 1d414bceb8
2 changed files with 6 additions and 2 deletions

View file

@ -148,7 +148,7 @@ var startCmd = &cobra.Command{
}
root, _ := adminRoot()
endpoints := []setup.Endpoint{{URL: fmt.Sprintf("http://%s:%s", "127.0.0.1", port), Interface: "localhost"}}
endpoints := []setup.Endpoint{{URL: fmt.Sprintf("http://%s%s", "127.0.0.1", port), Interface: "localhost"}}
switch host {
case "0.0.0.0":
// All interfaces

View file

@ -18,8 +18,12 @@ func Endpoints(cfg config.Config) ([]Endpoint, error) {
var endpoints []Endpoint
for _, network := range networks {
port := fmt.Sprintf(":%d", cfg.Port)
if port == ":80" {
port = ""
}
endpoint := Endpoint{
URL: fmt.Sprintf("http://%s:%d", network.IPv4, cfg.Port),
URL: fmt.Sprintf("http://%s%s", network.IPv4, port),
Interface: network.Interface,
}
endpoints = append(endpoints, endpoint)