Fix HTTP 307 redirect handling: configure HttpClient to follow redirects

This commit is contained in:
2026-01-30 12:49:58 -05:00
parent dda9736f8d
commit 1b79138923

View File

@@ -11,6 +11,7 @@ using allstarr.Services.Common;
using allstarr.Services.Lyrics; using allstarr.Services.Lyrics;
using allstarr.Middleware; using allstarr.Middleware;
using allstarr.Filters; using allstarr.Filters;
using Microsoft.Extensions.Http;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@@ -55,6 +56,17 @@ builder.Services.AddControllers()
}); });
builder.Services.AddHttpClient(); builder.Services.AddHttpClient();
builder.Services.ConfigureAll<HttpClientFactoryOptions>(options =>
{
options.HttpMessageHandlerBuilderActions.Add(builder =>
{
builder.PrimaryHandler = new HttpClientHandler
{
AllowAutoRedirect = true,
MaxAutomaticRedirections = 5
};
});
});
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(); builder.Services.AddSwaggerGen();
builder.Services.AddHttpContextAccessor(); builder.Services.AddHttpContextAccessor();