Stats API Url Fixed (#338)

* Fixed the API call by removing baseAddress and performing concatination in real time
This commit is contained in:
Joseph Milazzo 2021-06-25 15:08:55 -05:00 committed by GitHub
parent be56b33baf
commit 6b645737fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -16,7 +16,6 @@ namespace API.Extensions
{
services.AddHttpClient<StatsApiClient>(client =>
{
client.BaseAddress = new Uri("https://stats.kavitareader.com");
client.DefaultRequestHeaders.Add("api-key", "MsnvA2DfQqxSK5jh");
});

View File

@ -1,6 +1,7 @@
using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading;
using System.Threading.Tasks;
using API.Configurations.CustomOptions;
@ -15,6 +16,7 @@ namespace API.Services.Clients
private readonly HttpClient _client;
private readonly StatsOptions _options;
private readonly ILogger<StatsApiClient> _logger;
private const string ApiUrl = "http://stats.kavitareader.com";
public StatsApiClient(HttpClient client, IOptions<StatsOptions> options, ILogger<StatsApiClient> logger)
{
@ -29,7 +31,7 @@ namespace API.Services.Clients
try
{
var response = await _client.PostAsJsonAsync("/api/InstallationStats", data);
using var response = await _client.PostAsJsonAsync(ApiUrl + "/api/InstallationStats", data);
responseContent = await response.Content.ReadAsStringAsync();