Add user agent so non-api requests work again

This commit is contained in:
Gordon Pedersen 2024-06-24 11:41:03 +10:00
parent c7400ca42f
commit 434c84ce5c

View file

@ -3,7 +3,9 @@ using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;
using Neighbourhood.omg.lol.Models;
using System.Diagnostics;
using System.Net;
using System.Net.Http.Json;
using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
@ -17,6 +19,8 @@ namespace Neighbourhood.omg.lol {
public RestService(string? token = null) {
_client = new HttpClient();
_client.BaseAddress = new Uri(BaseUrl);
AssemblyName name = Assembly.GetExecutingAssembly().GetName();
_client.DefaultRequestHeaders.UserAgent.Add(new System.Net.Http.Headers.ProductInfoHeaderValue(name.Name ?? "Neighbourhood.omg.lol", name.Version?.ToString()));
_serializerOptions = new JsonSerializerOptions {
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
WriteIndented = true