From 3806bfc24ce0628ec8132413dc721a4c6c57eee7 Mon Sep 17 00:00:00 2001 From: Demis Bellot Date: Wed, 20 Nov 2024 16:15:47 +0800 Subject: [PATCH] force https scheme --- MyApp.Client/Program.cs | 6 ++---- MyApp/Program.cs | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/MyApp.Client/Program.cs b/MyApp.Client/Program.cs index db538ce..c100562 100644 --- a/MyApp.Client/Program.cs +++ b/MyApp.Client/Program.cs @@ -9,13 +9,11 @@ builder.Services.AddCascadingAuthenticationState(); builder.Services.AddSingleton(); -var baseUrl = "https://blazor-wasm.web-templates.io"; - // Use / for local or CDN resources -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(baseUrl) }); +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); var apiBaseUrl = builder.Configuration["ApiBaseUrl"] ?? builder.HostEnvironment.BaseAddress; -builder.Services.AddBlazorApiClient(baseUrl); +builder.Services.AddBlazorApiClient(apiBaseUrl); builder.Services.AddLocalStorage(); await builder.Build().RunAsync(); diff --git a/MyApp/Program.cs b/MyApp/Program.cs index 938032f..65a2bb1 100644 --- a/MyApp/Program.cs +++ b/MyApp/Program.cs @@ -62,6 +62,11 @@ services.AddServiceStack(typeof(MyServices).Assembly); var app = builder.Build(); +app.Use((context, next) => +{ + context.Request.Scheme = "https"; + return next(context); +}); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment())