diff --git a/src/Heimdall.Agent/Program.cs b/src/Heimdall.Agent/Program.cs index 4bbddae..5016f39 100644 --- a/src/Heimdall.Agent/Program.cs +++ b/src/Heimdall.Agent/Program.cs @@ -31,7 +31,8 @@ builder.Services.AddOptions() builder.Services.AddHttpClient("Central", (sp, client) => { var options = sp.GetRequiredService>().Value; - client.BaseAddress = new Uri(options.CentralUrl.TrimEnd('/') + "/"); + var baseUrl = options.CentralUrl.EndsWith('/') ? options.CentralUrl : options.CentralUrl + "/"; + client.BaseAddress = new Uri(baseUrl); client.Timeout = TimeSpan.FromSeconds(10); }); diff --git a/src/Heimdall.Web/Program.cs b/src/Heimdall.Web/Program.cs index ed79164..4484d5a 100644 --- a/src/Heimdall.Web/Program.cs +++ b/src/Heimdall.Web/Program.cs @@ -368,7 +368,8 @@ public partial class Program { ?? "http://localhost:8080"; builder.Services.AddHttpClient("HeimdallApi", client => { - client.BaseAddress = new Uri(apiBaseUrl.TrimEnd('/') + "/"); + var baseUrl = apiBaseUrl.EndsWith('/') ? apiBaseUrl : apiBaseUrl + "/"; + client.BaseAddress = new Uri(baseUrl); client.Timeout = TimeSpan.FromSeconds(30); }).AddHttpMessageHandler(); diff --git a/src/Heimdall.Web/Services/TokenRefreshHandler.cs b/src/Heimdall.Web/Services/TokenRefreshHandler.cs index cbd3b3a..793cbc6 100644 --- a/src/Heimdall.Web/Services/TokenRefreshHandler.cs +++ b/src/Heimdall.Web/Services/TokenRefreshHandler.cs @@ -81,7 +81,8 @@ public class TokenRefreshHandler : DelegatingHandler // Create a raw HttpClient (NOT the "HeimdallApi" named client which // includes this handler — would cause an infinite loop). - using var rawClient = new HttpClient { BaseAddress = new Uri(_apiBaseUrl.TrimEnd('/') + "/") }; + var baseUrl = _apiBaseUrl.EndsWith('/') ? _apiBaseUrl : _apiBaseUrl + "/"; + using var rawClient = new HttpClient { BaseAddress = new Uri(baseUrl) }; var response = await rawClient.PostAsJsonAsync( "api/auth/refresh", new { refreshToken = _authState.RefreshToken },