diff --git a/cli/config/config.go b/cli/config/config.go index d6ad567bdb..941b0bd8e7 100644 --- a/cli/config/config.go +++ b/cli/config/config.go @@ -44,7 +44,6 @@ type Config struct { func (c Config) OAuthEndpoint() string { return fmt.Sprintf("%s%s", c.URL(), c.Path()) - } func (c Config) URL() string { diff --git a/cli/config/configurator.go b/cli/config/configurator.go index 0ed8fd644f..999e4286cc 100644 --- a/cli/config/configurator.go +++ b/cli/config/configurator.go @@ -156,6 +156,7 @@ func (c Configurator) getServerURL(prev *Config) (string, error) { } func (c Configurator) createConfig(serverURL string) (Config, error) { + serverURL = strings.TrimSuffix(serverURL, "/") scheme, endpoint, path, err := ParseServerURL(serverURL) if err != nil { return Config{}, err diff --git a/cli/pkg/oauth/oauth.go b/cli/pkg/oauth/oauth.go index afb148a82f..4e5fb7f5a3 100644 --- a/cli/pkg/oauth/oauth.go +++ b/cli/pkg/oauth/oauth.go @@ -6,6 +6,7 @@ import ( "io" "net" "net/http" + neturl "net/url" "sync" "github.com/kubeshop/tracetest/cli/ui" @@ -58,7 +59,10 @@ func (s *OAuthServer) GetAuthJWT() error { return fmt.Errorf("failed to start oauth server: %w", err) } - loginUrl := fmt.Sprintf("%soauth?callback=%s", s.frontendEndpoint, url) + loginUrl, err := neturl.JoinPath(s.frontendEndpoint, fmt.Sprintf("oauth?callback=%s", url)) + if err != nil { + return fmt.Errorf("could not build path: %w", err) + } ui := ui.DefaultUI err = ui.OpenBrowser(loginUrl)