Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not set TargetPort to Port when IsProxying is also set #3372

Merged
merged 5 commits into from
Apr 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/Aspire.Hosting/Publishing/ManifestPublishingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,17 @@ public void WriteBindings(IResource resource)
Writer.WriteString("protocol", endpoint.Protocol.ToString().ToLowerInvariant());
Writer.WriteString("transport", endpoint.Transport);

int? targetPort = (resource, endpoint.UriScheme, endpoint.TargetPort) switch
int? targetPort = (resource, endpoint.UriScheme, endpoint.TargetPort, endpoint.Port) switch
{
// The port was specified so use it
(_, _, int port) => port,
(_, _, int target, _) => target,

// Project resources get their default port from the deployment tool
// Container resources get their default listening port from the exposed port.
(ContainerResource, _, _, int port) => port,

// Project resources get their default listening port from the deployment tool
// ideally we would default to a known port but we don't know it at this point
(ProjectResource, var scheme, null) when scheme is "http" or "https" => null,
(ProjectResource, var scheme, null, _) when scheme is "http" or "https" => null,

// Allocate a dynamic port
_ => PortAllocator.AllocatePort()
Expand Down
Loading