mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 23:09:41 +02:00
fix(endpoint handler): fix endpoint address(url) parsing EE-3081] (#7408)
fix address validation when creating agent endpoint
This commit is contained in:
parent
0141e55936
commit
4e9b3a8940
3 changed files with 12 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue