Skip to content

Commit

Permalink
Do not set TargetPort to Port when IsProxied is true
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenBond committed Apr 3, 2024
1 parent 2bba2ad commit 0526414
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,23 @@ public EndpointAnnotation(ProtocolType protocol, string? uriScheme = null, strin
_transport = transport;
Name = name;
Port = port;
TargetPort = targetPort ?? port;

TargetPort = targetPort;

// If the target port was not explicitly set and the service is not being proxied,
// we can set the target port to the port.
if (TargetPort is null && !isProxied)
{
TargetPort = port;
}

IsExternal = isExternal ?? false;
IsProxied = isProxied;

if (TargetPort is int && Port is int && TargetPort == Port && IsProxied)
{
throw new ArgumentException($"When {nameof(isProxied)} is true, {nameof(targetPort)} must not be equal to {nameof(port)}.");
}
}

/// <summary>
Expand Down

0 comments on commit 0526414

Please sign in to comment.