mirror of https://github.com/portainer/portainer
fix(endpoint handler): fix endpoint address(url) parsing EE-3081] (#7408)
fix address validation when creating agent endpointpull/7426/head
parent
0141e55936
commit
4e9b3a8940
|
@ -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}
|
||||
|
|
|
@ -130,7 +130,7 @@ export async function createRemoteEnvironment({
|
|||
}: CreateRemoteEnvironment) {
|
||||
return createEnvironment(name, creationType, {
|
||||
...options,
|
||||
url: `tcp://${url}`,
|
||||
url: `${url}`,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -8,10 +8,11 @@ export function EnvironmentUrlField() {
|
|||
|
||||
return (
|
||||
<FormControl
|
||||
label="Environment URL"
|
||||
label="Environment address"
|
||||
errors={meta.error}
|
||||
required
|
||||
inputId="environment-url-field"
|
||||
tooltip="A host:port combination. The host can be either an IP address or a host name."
|
||||
>
|
||||
<Field
|
||||
id="environment-url-field"
|
||||
|
|
Loading…
Reference in New Issue