In my Blazor web app(auto render mode), I have added the http client as service in server project like bellow:
builder.Services.AddHttpClient();I also added http client in the web assembly (client) project like bellow:
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });Now the problem is, when I inject HttpClient in my home page component(in client project), and try to use that service in OnInitializedAsync method, it throws an exception first time saying no base address is added, but in the OnAfterRenderAsync method the http client works fine with the correct base address.
What should I do to use the HttpClient in OnInitializedAsync method?