Draft
Blazor Gateway: read reverse-proxy config from the app project's config files#67910
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. YARPReverseProxyconfig could only be supplied via flattenedReverseProxy__...environment variables or command-line args — verbose, error-prone, and undiscoverable. This lets the gateway pick up the standardReverseProxysection straight from the app project's config files.Description
BlazorGateway.BuildWebHost: newAddAppProjectConfigurationstep reads anAppSettingsDirectorykey and registersappsettings.json+appsettings.{Environment}.jsonfrom that directory via aPhysicalFileProvider(needed since the gateway's content root differs from the app project).command-line > env vars > appsettings.{Environment}.json > appsettings.json. The existing env-var/launchSettings.jsonapproach 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.).ReverseProxyforwarding and forappsettings.{Environment}.jsonoverriding 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/" } } } } } }