fix: response leak, TrackProxyController rename, restore api.json load

This commit is contained in:
Daniel Harvey
2026-05-25 19:37:27 -04:00
parent e2a7944077
commit 2e8233d9d3
2 changed files with 9 additions and 4 deletions
@@ -10,13 +10,13 @@ namespace DeepDrftPublic.Controllers;
/// named clients — no proxy hop needed on the server side.
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class TrackController : ControllerBase
[Route("api/track")]
public class TrackProxyController : ControllerBase
{
private readonly HttpClient _upstream;
private readonly ILogger<TrackController> _logger;
private readonly ILogger<TrackProxyController> _logger;
public TrackController(IHttpClientFactory httpClientFactory, ILogger<TrackController> logger)
public TrackProxyController(IHttpClientFactory httpClientFactory, ILogger<TrackProxyController> logger)
{
_upstream = httpClientFactory.CreateClient("DeepDrft.API");
_logger = logger;
@@ -103,6 +103,7 @@ public class TrackController : ControllerBase
Response.ContentLength = contentLength.Value;
var stream = await upstream.Content.ReadAsStreamAsync(ct);
HttpContext.Response.RegisterForDispose(upstream);
return File(stream, contentType, enableRangeProcessing: false);
}
}
+4
View File
@@ -2,12 +2,16 @@ using DeepDrftPublic;
using MudBlazor.Services;
using DeepDrftPublic.Components;
using Microsoft.AspNetCore.HttpOverrides;
using NetBlocks.Utilities.Environment;
var builder = WebApplication.CreateBuilder(args);
// Add MudBlazor services
builder.Services.AddMudServices();
var apiPath = CredentialTools.ResolvePathOrThrow("api", "environment/api.json");
builder.Configuration.AddJsonFile(apiPath, optional: false, reloadOnChange: false);
var contentApiUrl = builder.Configuration["ApiUrls:ContentApi"] ?? throw new Exception("Content API URL is not configured");
var sqlApiUrl = builder.Configuration["ApiUrls:SqlApi"] ?? throw new Exception("ApiUrls:SqlApi is not configured");