diff --git a/api/http/handler/endpoints/endpoint_create.go b/api/http/handler/endpoints/endpoint_create.go index a0d7bf20e..a97c3c79d 100644 --- a/api/http/handler/endpoints/endpoint_create.go +++ b/api/http/handler/endpoints/endpoint_create.go @@ -258,6 +258,15 @@ func (handler *Handler) createEndpoint(payload *endpointCreatePayload) (*portain endpointType := portainer.DockerEnvironment if payload.EndpointCreationType == agentEnvironment { + + // Case insensitive strip http or https scheme if URL entered + index := strings.Index(payload.URL, "://") + if index >= 0 { + payload.URL = payload.URL[index+3:] + } + + payload.URL = "tcp://" + payload.URL + agentPlatform, err := handler.pingAndCheckPlatform(payload) if err != nil { return nil, &httperror.HandlerError{http.StatusInternalServerError, "Unable to get environment type", err} diff --git a/app/portainer/environments/environment.service/create.ts b/app/portainer/environments/environment.service/create.ts index 42630c4c0..87df20c9e 100644 --- a/app/portainer/environments/environment.service/create.ts +++ b/app/portainer/environments/environment.service/create.ts @@ -130,7 +130,7 @@ export async function createRemoteEnvironment({ }: CreateRemoteEnvironment) { return createEnvironment(name, creationType, { ...options, - url: `tcp://${url}`, + url: `${url}`, }); } diff --git a/app/react/portainer/environments/wizard/EnvironmentsCreationView/shared/AgentForm/EnvironmentUrlField.tsx b/app/react/portainer/environments/wizard/EnvironmentsCreationView/shared/AgentForm/EnvironmentUrlField.tsx index d28a0c584..7789520eb 100644 --- a/app/react/portainer/environments/wizard/EnvironmentsCreationView/shared/AgentForm/EnvironmentUrlField.tsx +++ b/app/react/portainer/environments/wizard/EnvironmentsCreationView/shared/AgentForm/EnvironmentUrlField.tsx @@ -8,10 +8,11 @@ export function EnvironmentUrlField() { return (