FilterCair_Stack/FilterCair.Client/Program.cs
2025-11-04 19:47:29 +01:00

25 lines
988 B
C#

using FilterCair.Client;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
var apiBase = builder.Configuration["Api:BaseUrl"];
builder.Services.AddHttpClient("FilterCair.ServerAPI", client =>
client.BaseAddress = new Uri(apiBase))
.AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(apiBase) });
builder.Services.AddMsalAuthentication(options =>
{
builder.Configuration.Bind("AzureAd", options.ProviderOptions.Authentication);
options.ProviderOptions.DefaultAccessTokenScopes.Add(
"api://54b010c7-4a9a-4f2d-bea3-9faba3f12495/API.Access");
});
await builder.Build().RunAsync();