From this post: https://stackoverflow.com/a/78353968/8031370
In App.razor:
<base href="@BaseUrl" />
At the bottom of App.razor add:
@code {
[CascadingParameter]
private HttpContext HttpContext { get; set; } = null!;
private string BaseUrl => $"{HttpContext.Request.PathBase}/";
}