Skip to content

Commit

Permalink
fix(be): check port format
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftin committed Sep 20, 2023
1 parent bc32109 commit 67099f1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/spf13/cobra"
"net/http"
"os"
"strings"
)

var configPath string
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 67099f1

Please sign in to comment.