2026-07-16 21:19:16 +00:00
|
|
|
using System.Security.Claims;
|
2026-07-16 19:09:28 +00:00
|
|
|
using Heimdall.Web.Components;
|
2026-07-16 21:19:16 +00:00
|
|
|
using Heimdall.Web.Services;
|
|
|
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
|
|
|
using MudBlazor.Services;
|
2026-07-16 19:09:28 +00:00
|
|
|
|
2026-07-18 20:31:37 +00:00
|
|
|
// ── Sentry (GlitchTip) — DSN from env var, with hardcoded fallback ─
|
|
|
|
|
var sentryDsn = Environment.GetEnvironmentVariable("SENTRY_DSN")
|
|
|
|
|
?? "https://db94b9fc2f36425f9eb4b9f6f347dc73@glitchtip.tordais.cc/6";
|
2026-07-18 19:41:57 +00:00
|
|
|
|
2026-07-16 19:09:28 +00:00
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
2026-07-18 19:41:57 +00:00
|
|
|
// ── Sentry ────────────────────────────────────────────────────────
|
|
|
|
|
builder.WebHost.UseSentry(options =>
|
|
|
|
|
{
|
2026-07-18 20:31:37 +00:00
|
|
|
options.Dsn = sentryDsn;
|
2026-07-18 19:41:57 +00:00
|
|
|
options.MinimumBreadcrumbLevel = LogLevel.Debug;
|
|
|
|
|
options.MinimumEventLevel = LogLevel.Error;
|
|
|
|
|
options.TracesSampleRate = 0.1;
|
|
|
|
|
});
|
|
|
|
|
|
2026-07-16 19:09:28 +00:00
|
|
|
builder.Services.AddRazorComponents()
|
|
|
|
|
.AddInteractiveServerComponents();
|
|
|
|
|
|
2026-07-16 21:19:16 +00:00
|
|
|
// Auth for Blazor
|
|
|
|
|
builder.Services.AddScoped<AuthenticationStateProvider, HeimdallAuthStateProvider>();
|
|
|
|
|
builder.Services.AddAuthorizationCore();
|
2026-07-18 18:58:20 +00:00
|
|
|
builder.Services.AddCascadingAuthenticationState();
|
2026-07-16 21:19:16 +00:00
|
|
|
|
|
|
|
|
builder.Services.AddMudServices(config =>
|
|
|
|
|
{
|
|
|
|
|
config.SnackbarConfiguration.PositionClass = "mud-alert-center-top";
|
|
|
|
|
config.SnackbarConfiguration.PreventDuplicates = true;
|
|
|
|
|
config.SnackbarConfiguration.ShowCloseIcon = true;
|
|
|
|
|
config.SnackbarConfiguration.VisibleStateDuration = 4000;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
builder.Services.AddScoped<HeimdallApiClient>();
|
2026-07-17 13:22:02 +00:00
|
|
|
var apiBaseUrl = builder.Configuration.GetValue<string>("ApiBaseUrl")
|
|
|
|
|
?? Environment.GetEnvironmentVariable("API_BASE_URL")
|
|
|
|
|
?? "http://localhost:5000";
|
2026-07-16 21:19:16 +00:00
|
|
|
builder.Services.AddHttpClient("HeimdallApi", client =>
|
|
|
|
|
{
|
2026-07-17 13:22:02 +00:00
|
|
|
client.BaseAddress = new Uri(apiBaseUrl.TrimEnd('/') + "/");
|
2026-07-16 21:19:16 +00:00
|
|
|
client.Timeout = TimeSpan.FromSeconds(30);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Auth state
|
|
|
|
|
builder.Services.AddScoped<AuthState>();
|
|
|
|
|
|
2026-07-16 19:09:28 +00:00
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
|
|
|
{
|
|
|
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
|
|
|
app.UseHsts();
|
|
|
|
|
}
|
2026-07-16 21:19:16 +00:00
|
|
|
|
2026-07-16 19:09:28 +00:00
|
|
|
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
app.UseAntiforgery();
|
|
|
|
|
app.MapStaticAssets();
|
|
|
|
|
app.MapRazorComponents<App>()
|
|
|
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
|
|
|
|
|
|
app.Run();
|