From 60244f4dd6b4e034a0d843c53a1b05bb5c08d9c4 Mon Sep 17 00:00:00 2001 From: Byakuya Date: Thu, 4 Sep 2025 19:37:55 +0200 Subject: [PATCH] Correction --- Program.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Program.cs b/Program.cs index ed89239..395287a 100644 --- a/Program.cs +++ b/Program.cs @@ -4,6 +4,7 @@ using administration.Models.HelloFresh; using administration.Services; using IngredientsAI.Services; using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using System.Text.Json; @@ -94,13 +95,21 @@ namespace administration var baseUrl = cfg["Ollama:Url"] ?? "http://ollama:11434"; client.BaseAddress = new Uri(baseUrl); client.Timeout = TimeSpan.FromSeconds(25); - }) + }); + +var ollamaBuilder = builder.Services.AddHttpClient("ollama", (sp, client) => +{ + var cfg = sp.GetRequiredService(); + var baseUrl = cfg["Ollama:Url"] ?? "http://ollama:11434"; + client.BaseAddress = new Uri(baseUrl); + client.Timeout = TimeSpan.FromSeconds(25); +}); #if DEBUG - .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler - { - ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator - }); - #endif + ollamaBuilder.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler + { + ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + }); +#endif // ... // ... @@ -118,6 +127,7 @@ namespace administration app.UseHttpsRedirection(); app.UseStaticFiles(); + app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); app.UseRouting(); app.UseCors("AllowFrontend");