diff --git a/TaxBaik.Web/Program.cs b/TaxBaik.Web/Program.cs index 9fe1141..8dacc37 100644 --- a/TaxBaik.Web/Program.cs +++ b/TaxBaik.Web/Program.cs @@ -229,8 +229,7 @@ builder.Services.AddHttpClient(client builder.Services.AddHttpClient(client => { client.BaseAddress = new Uri(apiBaseUrl); -}) - .AddHttpMessageHandler(); +}); builder.Services.AddHttpClient(client => { client.BaseAddress = new Uri(apiBaseUrl); diff --git a/TaxBaik.Web/Services/TaxFilingBrowserClient.cs b/TaxBaik.Web/Services/TaxFilingBrowserClient.cs index f0fd6c2..cd3afb2 100644 --- a/TaxBaik.Web/Services/TaxFilingBrowserClient.cs +++ b/TaxBaik.Web/Services/TaxFilingBrowserClient.cs @@ -32,10 +32,10 @@ public class TaxFilingBrowserClient : ITaxFilingBrowserClient private void EnsureAuthHeader() { - if (!string.IsNullOrEmpty(_tokenStore.AccessToken) && !_http.DefaultRequestHeaders.Contains("Authorization")) - { + if (!string.IsNullOrEmpty(_tokenStore.AccessToken)) _http.DefaultRequestHeaders.Authorization = new("Bearer", _tokenStore.AccessToken); - } + else + _http.DefaultRequestHeaders.Authorization = null; } public async Task> GetUpcomingAsync(int daysAhead = 30, CancellationToken ct = default) @@ -44,7 +44,7 @@ public class TaxFilingBrowserClient : ITaxFilingBrowserClient { EnsureAuthHeader(); var result = await _http.GetFromJsonAsync( - $"tax-filing/upcoming?daysAhead={daysAhead}", cancellationToken: ct); + $"api/taxfiling/upcoming?daysAhead={daysAhead}", cancellationToken: ct); return result?.Data ?? []; } catch (HttpRequestException ex) @@ -60,7 +60,7 @@ public class TaxFilingBrowserClient : ITaxFilingBrowserClient { EnsureAuthHeader(); var result = await _http.GetFromJsonAsync( - $"tax-filing/client/{clientId}", cancellationToken: ct); + $"api/taxfiling/client/{clientId}", cancellationToken: ct); return result?.Data ?? []; } catch (HttpRequestException ex) @@ -76,7 +76,7 @@ public class TaxFilingBrowserClient : ITaxFilingBrowserClient { EnsureAuthHeader(); return await _http.GetFromJsonAsync( - $"tax-filing/{id}", cancellationToken: ct); + $"api/taxfiling/{id}", cancellationToken: ct); } catch (HttpRequestException ex) { @@ -90,7 +90,7 @@ public class TaxFilingBrowserClient : ITaxFilingBrowserClient try { EnsureAuthHeader(); - var response = await _http.PostAsJsonAsync("tax-filing", filing, cancellationToken: ct); + var response = await _http.PostAsJsonAsync("api/taxfiling", filing, cancellationToken: ct); if (!response.IsSuccessStatusCode) return null; @@ -111,7 +111,7 @@ public class TaxFilingBrowserClient : ITaxFilingBrowserClient try { EnsureAuthHeader(); - var response = await _http.PutAsJsonAsync($"tax-filing/{id}", filing, cancellationToken: ct); + var response = await _http.PutAsJsonAsync($"api/taxfiling/{id}", filing, cancellationToken: ct); if (!response.IsSuccessStatusCode) return null; @@ -132,7 +132,7 @@ public class TaxFilingBrowserClient : ITaxFilingBrowserClient try { EnsureAuthHeader(); - var response = await _http.DeleteAsync($"tax-filing/{id}", cancellationToken: ct); + var response = await _http.DeleteAsync($"api/taxfiling/{id}", cancellationToken: ct); return response.IsSuccessStatusCode; } catch (HttpRequestException ex)