-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (42 loc) · 1.79 KB
/
Copy pathProgram.cs
File metadata and controls
57 lines (42 loc) · 1.79 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
using Microsoft.AspNetCore.Components.Web;
using MudBlazor.Services;
using BroadcastManager2;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.HttpOverrides;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddScoped<AuthenticationStateProvider, CustomAuthenticationStateProvider>();
builder.Services.AddHttpClient();
builder.Services.AddDataProtection()
.SetApplicationName( "Broadcast Manager" );
builder.Services.AddMudServices();
var app = builder.Build();
// import appsettings.json
var settings = app.Configuration.Get<AppSettings>();
// update dns records so that the broadcast manager can be found
//var dnsSplit = DnsHelper.SplitDnsName(AppSettings.LocalServerDnsName ?? "");
string ipv4Address = DnsHelper.GetLocalIPv4();
if ( !string.IsNullOrWhiteSpace( AppSettings.CloudFlareTokenKey ) && !string.IsNullOrWhiteSpace( AppSettings.DomainName ) )
{
var dns = new UpdateCloudflareDNS(AppSettings.CloudFlareTokenKey ?? "");
await dns.UpdateDnsAsync( AppSettings.DomainName, AppSettings.LocalServerDnsHostName, ipv4Address, new CancellationToken() );
}
if ( !app.Environment.IsDevelopment() )
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseForwardedHeaders( new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
} );
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.MapBlazorHub();
app.MapFallbackToPage( "/_Host" );
app.Run();