Added YARP reverse proxy for API routing and DevExpress Blazor components for advanced UI features, including PDF Viewer. Updated `EnvelopeGenerator.WebUI.csproj` to include necessary packages and ensure `yarp.json` is copied to the output directory. Modified `Program.cs` to configure YARP and DevExpress services, and adjusted the HTTP pipeline for proper routing. Updated `appsettings.json` with `ApiOptions` and `PdfViewerOptions`. Added `yarp.json` to define reverse proxy routes and clusters.
58 lines
1.9 KiB
C#
58 lines
1.9 KiB
C#
using EnvelopeGenerator.WebUI.Components;
|
|
using DevExpress.Blazor;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Load YARP configuration
|
|
builder.Configuration.AddJsonFile("yarp.json", optional: false, reloadOnChange: true);
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents()
|
|
.AddInteractiveWebAssemblyComponents();
|
|
|
|
// YARP Reverse Proxy
|
|
builder.Services.AddReverseProxy()
|
|
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
|
|
|
|
// DevExpress Server-Side Services (CRITICAL for DxPdfViewer)
|
|
builder.Services.AddDevExpressBlazor(configure => configure.BootstrapVersion = BootstrapVersion.v5);
|
|
builder.Services.AddDevExpressServerSideBlazorPdfViewer();
|
|
// builder.Services.AddDevExpressBlazorReportViewer(); // Will be enabled after Options migration
|
|
|
|
// Configuration Options (will be enabled in Phase 5 after Options migration)
|
|
// builder.Services.Configure<EnvelopeGenerator.WebUI.Client.Options.ApiOptions>(
|
|
// builder.Configuration.GetSection("ApiOptions"));
|
|
// builder.Services.Configure<EnvelopeGenerator.WebUI.Client.Options.PdfViewerOptions>(
|
|
// builder.Configuration.GetSection("PdfViewerOptions"));
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseWebAssemblyDebugging();
|
|
}
|
|
else
|
|
{
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
// 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.UseHttpsRedirection();
|
|
|
|
app.UseStaticFiles();
|
|
app.UseAntiforgery();
|
|
|
|
// Blazor routing (BEFORE YARP - important order!)
|
|
app.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode()
|
|
.AddInteractiveWebAssemblyRenderMode()
|
|
.AddAdditionalAssemblies(typeof(EnvelopeGenerator.WebUI.Client._Imports).Assembly);
|
|
|
|
// YARP proxy (AFTER Blazor - catch-all for /api/*)
|
|
app.MapReverseProxy();
|
|
|
|
app.Run();
|