Skip to content

YARP resource WithHostHttpsPort() still randomizes port #13674

@halllo

Description

@halllo

I have a YARP resource and want to use it as an API gateway towards my other resources (source).

var builder = DistributedApplication.CreateBuilder(args);

var identity = builder.AddProject<Projects.Identity>("Identity");

var backend = builder.AddProject<Projects.Backend>("Backend");

var frontend = builder.AddViteApp("Frontend", "../Frontend");

var gateway = builder.AddYarp("Gateway")
                     .WithHostHttpsPort(8443)
                     .WithHostPort(8080)
                     .WithConfiguration(yarp =>
                     {
                        yarp.AddRoute("/identity/{**catch-all}", identity);
                        yarp.AddRoute("/backend/{**catch-all}", backend);
                        yarp.AddRoute("/frontend/{**catch-all}", frontend);
                     });

builder.Build().Run();

Unfortunately it does not accept my HTTPS port but keeps randomly assigning a port. For HTTP it accepts my port.

Image

The docs say this will only have effect if an HTTPS endpoint is configured on the YARP resource due to TLS termination being enabled. I clearly have an HTTPS endpoint and when I attempt to add one explicitly, I get a Aspire.Hosting.DistributedApplicationException: Endpoint with name 'https' already exists.

What can I do to give my YARP gateway resource a static port?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions