microsoft / microsoft/aspire

Add PathBaseMiddleware to Aspire Dashboard

Open
#4,528 8 comments 9 reactions 0 assignees View on GitHub
area-dashboard
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

Hi 👋🏻

**Disclaimer:** Since my issue is more a feature request than an API change, I decided not to use one of the predefined templates, but I'm happy to provide any further information you need.

I'm running the Aspire Dashboard as a standalone app via Docker which works nicely 👌🏻 Since multiple Dockerized .NET apps are running on my host, I separated them by making use of the [`PathBaseMiddleware`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.builder.usepathbaseextensions.usepathbase). This way, I can easily reroute them like this:

```c#
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.UsePathBase("/myapp");
```

Applying this pattern to the Aspire Dashboard would probably mean adding the following code to [`DashboardWebApplication.cs`](https://github.com/dotnet/aspire/blob/main/src/Aspire.Dashboard/DashboardWebApplication.cs):

```c#
if (!string.IsNullOrEmpty(builder.Configuration[DashboardConfigNames.PathBase]))
{
app.UsePathBase(builder.Configuration[DashboardConfigNames.PathBase]); // maybe sanitize PathBase here
}
```

This way, I could easily reroute the Aspire Dashboard and make it accessible on `https://myhost/aspire-dashboard` instead of using a dedicated port (e.g. `https://myhost:18888/`). A corresponding `docker-compose.yml` could look like this:

```yaml
services:
aspire-dashboard:
image: mcr.microsoft.com/dotnet/aspire-dashboard
container_name: aspire-dashboard
ports:
- 4317:18889
- 18888:18888
environment:
- Dashboard__PathBase=/aspire-dashboard
```

However, I didn't do a comprehensive and all-encompassing review of the implications and whether this might break certain features - but at least I want to trigger a discussion 🙂

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.