-
Notifications
You must be signed in to change notification settings - Fork 660
/
Program.cs
35 lines (26 loc) · 1.24 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using BlazorWasmAuth.Components;
using BlazorWasmAuth.Identity;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
// register the cookie handler
builder.Services.AddTransient<CookieHandler>();
// set up authorization
builder.Services.AddAuthorizationCore();
// register the custom state provider
builder.Services.AddScoped<AuthenticationStateProvider, CookieAuthenticationStateProvider>();
// register the account management interface
builder.Services.AddScoped(
sp => (IAccountManagement)sp.GetRequiredService<AuthenticationStateProvider>());
// set base address for default host
builder.Services.AddScoped(sp =>
new HttpClient { BaseAddress = new Uri(builder.Configuration["FrontendUrl"] ?? "https://localhost:5002") });
// configure client for auth interactions
builder.Services.AddHttpClient(
"Auth",
opt => opt.BaseAddress = new Uri(builder.Configuration["BackendUrl"] ?? "https://localhost:5001"))
.AddHttpMessageHandler<CookieHandler>();
await builder.Build().RunAsync();