From 67099f1031e7c1a7e777259254c580681779336e Mon Sep 17 00:00:00 2001 From: Denis Gukov Date: Wed, 20 Sep 2023 10:22:26 +0200 Subject: [PATCH] fix(be): check port format --- cli/cmd/root.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cli/cmd/root.go b/cli/cmd/root.go index 90b206d08..c815dab61 100644 --- a/cli/cmd/root.go +++ b/cli/cmd/root.go @@ -15,6 +15,7 @@ import ( "github.com/spf13/cobra" "net/http" "os" + "strings" ) var configPath string @@ -48,6 +49,12 @@ func runService() { util.Config.PrintDbInfo() + port := util.Config.Port + + if !strings.HasPrefix(port, ":") { + port = ":" + port + } + fmt.Printf("Tmp Path (projects home) %v\n", util.Config.TmpPath) fmt.Printf("Semaphore %v\n", util.Version) fmt.Printf("Interface %v\n", util.Config.Interface) @@ -81,7 +88,7 @@ func runService() { store.Close("root") } - err := http.ListenAndServe(util.Config.Interface+util.Config.Port, cropTrailingSlashMiddleware(router)) + err := http.ListenAndServe(util.Config.Interface+port, cropTrailingSlashMiddleware(router)) if err != nil { log.Panic(err)