Fix OpenAPI server URLs for Aspire scenarios by captainsafia · Pull Request #60673 · dotnet/aspnetcore (original) (raw)
Description
This PR supports respecting he X-Forwarded-Proto and X-Forwarded-Host headers when generating server URLs in OpenAPI documents. When these headers are present in the request, the OpenAPI document service will use them to generate the correct server URLs instead of using the original host and scheme values derived from the service configuration.
This is particularly useful in environments where the API is behind a proxy, load balancer, or gateway, allowing the generated OpenAPI document to correctly reference the public-facing URL rather than the internal service URL.
Fixes #57332
Customer Impact
Without this change, documents served behind reverse proxies or forwarded endpoints do not reflect the correct service URl, particularly impact for the ASP.NET Core + Aspire scenario. While the issue is easy to workaround, we want a smoother experience with Aspire out-of-the-box.
Regression?
- Yes
- No
Risk
- High
- Medium
- Low
Low-risk, becase change as it only affects the generation of server URLs in OpenAPI documents and does not impact the actual API functionality.
Verification
- Manual (required)
- Automated
Packaging changes reviewed?
- Yes
- No
- N/A