Skip to content

Blazor Gateway: read reverse-proxy config from the app project's config files#67910

Draft
oroztocil with Copilot wants to merge 2 commits into
mainfrom
copilot/blazor-gateway-read-reverse-proxy-config
Draft

Blazor Gateway: read reverse-proxy config from the app project's config files#67910
oroztocil with Copilot wants to merge 2 commits into
mainfrom
copilot/blazor-gateway-read-reverse-proxy-config

Conversation

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

The dev-time Blazor Gateway runs with its content root set to the package's tools folder, so it never reads the WASM app project's appsettings.json / appsettings.Development.json. YARP ReverseProxy config could only be supplied via flattened ReverseProxy__... environment variables or command-line args — verbose, error-prone, and undiscoverable. This lets the gateway pick up the standard ReverseProxy section straight from the app project's config files.

Description

  • BlazorGateway.BuildWebHost: new AddAppProjectConfiguration step reads an AppSettingsDirectory key and registers appsettings.json + appsettings.{Environment}.json from that directory via a PhysicalFileProvider (needed since the gateway's content root differs from the app project).
  • Source precedence: the file sources are inserted just ahead of the environment-variable and command-line sources, preserving command-line > env vars > appsettings.{Environment}.json > appsettings.json. The existing env-var/launchSettings.json approach keeps working.
  • Microsoft.AspNetCore.Components.Gateway.targets: run arguments now pass --AppSettingsDirectory "$(MSBuildProjectDirectory)" so the gateway knows where the app project lives (VS F5, dotnet run, etc.).
  • Tests: added coverage for config-file-based ReverseProxy forwarding and for appsettings.{Environment}.json overriding the base file.

Users can now configure the proxy with the standard, IntelliSense-friendly section:

{
  "ReverseProxy": {
    "Routes": {
      "weather": { "ClusterId": "backend", "Match": { "Path": "/api/{**catch-all}" } }
    },
    "Clusters": {
      "backend": { "Destinations": { "backend1": { "Address": "http://localhost:5100/" } } }
    }
  }
}

Co-authored-by: oroztocil <79744616+oroztocil@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve Blazor Gateway configuration by reading from app config files Blazor Gateway: read reverse-proxy config from the app project's config files Jul 20, 2026
Copilot AI requested a review from oroztocil July 20, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blazor Gateway: read reverse-proxy configuration from the app project's config files

2 participants