From 98d28d5b91db815159a93b2687a1175f1672f959 Mon Sep 17 00:00:00 2001 From: Lucas Morgan Date: Sat, 10 Feb 2024 21:02:22 -0600 Subject: [PATCH 1/2] Update some packages. --- Shogi.Api/Shogi.Api.csproj | 2 +- Tests/AcceptanceTests/AcceptanceTests.csproj | 2 +- Tests/E2ETests/E2ETests.csproj | 6 +++--- Tests/UnitTests/UnitTests.csproj | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Shogi.Api/Shogi.Api.csproj b/Shogi.Api/Shogi.Api.csproj index 0871023..18aae69 100644 --- a/Shogi.Api/Shogi.Api.csproj +++ b/Shogi.Api/Shogi.Api.csproj @@ -29,7 +29,7 @@ - + diff --git a/Tests/AcceptanceTests/AcceptanceTests.csproj b/Tests/AcceptanceTests/AcceptanceTests.csproj index 15efd8f..c0d9337 100644 --- a/Tests/AcceptanceTests/AcceptanceTests.csproj +++ b/Tests/AcceptanceTests/AcceptanceTests.csproj @@ -29,7 +29,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/E2ETests/E2ETests.csproj b/Tests/E2ETests/E2ETests.csproj index 4cb444e..d91738a 100644 --- a/Tests/E2ETests/E2ETests.csproj +++ b/Tests/E2ETests/E2ETests.csproj @@ -9,11 +9,11 @@ - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/UnitTests/UnitTests.csproj b/Tests/UnitTests/UnitTests.csproj index 7885685..5572e69 100644 --- a/Tests/UnitTests/UnitTests.csproj +++ b/Tests/UnitTests/UnitTests.csproj @@ -9,7 +9,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive From ffdeabe54a17dd07696829a056bbffb0ca78ec12 Mon Sep 17 00:00:00 2001 From: Lucas Morgan Date: Sat, 10 Feb 2024 21:02:48 -0600 Subject: [PATCH 2/2] Try manually crafting request urls to fix deploy-only bug. --- Shogi.UI/Pages/Home/Api/ShogiApi.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Shogi.UI/Pages/Home/Api/ShogiApi.cs b/Shogi.UI/Pages/Home/Api/ShogiApi.cs index a1a39e7..2e7b2eb 100644 --- a/Shogi.UI/Pages/Home/Api/ShogiApi.cs +++ b/Shogi.UI/Pages/Home/Api/ShogiApi.cs @@ -16,13 +16,16 @@ namespace Shogi.UI.Pages.Home.Api private readonly AccountState accountState; private readonly HttpClient guestHttpClient; private readonly HttpClient msalHttpClient; + private readonly string baseUrl; - public ShogiApi(IHttpClientFactory clientFactory, AccountState accountState) + public ShogiApi(IHttpClientFactory clientFactory, AccountState accountState, IConfiguration configuration) { this.serializerOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web); this.accountState = accountState; this.guestHttpClient = clientFactory.CreateClient(GuestClientName); this.msalHttpClient = clientFactory.CreateClient(MsalClientName); + this.baseUrl = configuration["ShogiApiUrl"] ?? throw new InvalidOperationException("Configuration missing."); + this.baseUrl = this.baseUrl.TrimEnd('/'); } private HttpClient HttpClient => accountState.User?.WhichAccountPlatform switch @@ -40,7 +43,7 @@ namespace Shogi.UI.Pages.Home.Api public async Task GetSession(string name) { - var response = await HttpClient.GetAsync(new Uri($"Sessions/{name}", UriKind.Relative)); + var response = await HttpClient.GetAsync(RelativeUri($"Sessions/{name}")); if (response.IsSuccessStatusCode) { return (await response.Content.ReadFromJsonAsync(serializerOptions))?.Session; @@ -98,6 +101,6 @@ namespace Shogi.UI.Pages.Home.Api return HttpClient.PatchAsync(RelativeUri($"Sessions/{name}/Join"), null); } - private static Uri RelativeUri(string path) => new(path, UriKind.Relative); + private Uri RelativeUri(string path) => new($"{this.baseUrl}/{path}", UriKind.Absolute); } }