Skip to content

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.

Stats API Url Fixed (#338)

Joseph Milazzo6b645737fa08
diff --git a/API/Extensions/ServiceCollectionExtensions.cs b/API/Extensions/ServiceCollectionExtensions.cs
index 62a0575ef..3559f3856 100644
--- a/API/Extensions/ServiceCollectionExtensions.cs
+++ b/API/Extensions/ServiceCollectionExtensions.cs
@@ -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");
});
diff --git a/API/Services/Clients/StatsApiClient.cs b/API/Services/Clients/StatsApiClient.cs
index 00dddfad3..e07bec222 100644
--- a/API/Services/Clients/StatsApiClient.cs
+++ b/API/Services/Clients/StatsApiClient.cs
@@ -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();