2021-11-13 03:21:59 +00:00
|
|
|
using System;
|
|
|
|
using System.Net.Http;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
|
|
|
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2021-11-21 06:47:10 +00:00
|
|
|
using Blazored.LocalStorage;
|
2021-11-13 03:21:59 +00:00
|
|
|
|
2021-11-21 06:47:10 +00:00
|
|
|
namespace Start.Client {
|
|
|
|
public class Program {
|
|
|
|
public static async Task Main(string[] args) {
|
|
|
|
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
|
|
|
builder.RootComponents.Add<App>("#app");
|
2021-11-13 03:21:59 +00:00
|
|
|
|
2021-11-21 06:47:10 +00:00
|
|
|
builder.Services.AddHttpClient("Start.ServerAPI",
|
|
|
|
client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress))
|
|
|
|
.AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();
|
2021-11-13 03:21:59 +00:00
|
|
|
|
2021-11-21 06:47:10 +00:00
|
|
|
// Supply HttpClient instances that include access tokens when making requests to the server project
|
|
|
|
builder.Services.AddScoped(sp => sp.GetRequiredService<IHttpClientFactory>()
|
|
|
|
.CreateClient("Start.ServerAPI"));
|
2021-11-13 03:21:59 +00:00
|
|
|
|
2021-11-21 06:47:10 +00:00
|
|
|
builder.Services.AddApiAuthorization();
|
2021-11-13 03:21:59 +00:00
|
|
|
|
2021-11-21 06:47:10 +00:00
|
|
|
builder.Services.AddBlazoredLocalStorage();
|
|
|
|
|
|
|
|
await builder.Build().RunAsync();
|
|
|
|
}
|
|
|
|
}
|
2021-11-13 03:21:59 +00:00
|
|
|
}
|