From f7b479a7595d2ee4e56f3ffdb202eb62ebfc752a Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Tue, 17 Nov 2026 22:53:19 -0500 Subject: [PATCH] Eliminate warnings; serve local htmx - Pin non-vulnerable dependency --- src/Directory.Packages.props | 38 +++++++++++++++-------------- src/PrayerTracker.UI/Layout.fs | 2 +- src/PrayerTracker/App.fs | 44 +++++++++++++++++++--------------- 3 files changed, 46 insertions(+), 38 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index cdeee7d..e05ada3 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -1,25 +1,27 @@ true + true - - - - - + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/src/PrayerTracker.UI/Layout.fs b/src/PrayerTracker.UI/Layout.fs index 583d7d5..ca129ef 100644 --- a/src/PrayerTracker.UI/Layout.fs +++ b/src/PrayerTracker.UI/Layout.fs @@ -278,7 +278,7 @@ let private pageLayout viewInfo pgTitle content = (contentSection viewInfo pgTitle content) match viewInfo.Layout with | FullPage -> - Script.minified + Script.local script [ _src "/js/ckeditor/ckeditor.js" ] [] script [ _src "/js/app.js" ] [] | _ -> () ] diff --git a/src/PrayerTracker/App.fs b/src/PrayerTracker/App.fs index 3d8011b..9ecbed4 100644 --- a/src/PrayerTracker/App.fs +++ b/src/PrayerTracker/App.fs @@ -15,13 +15,14 @@ open System open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Hosting open Microsoft.Extensions.Configuration +open Microsoft.Extensions.Hosting /// Module to hold configuration for the web app [] module Configure = /// Set up the configuration for the app - let configuration (ctx: WebHostBuilderContext) (cfg: IConfigurationBuilder) = + let configuration (ctx: HostBuilderContext) (cfg: IConfigurationBuilder) = cfg.SetBasePath(ctx.HostingEnvironment.ContentRootPath) .AddJsonFile("appsettings.json", optional = true, reloadOnChange = true) .AddJsonFile($"appsettings.{ctx.HostingEnvironment.EnvironmentName}.json", optional = true) @@ -37,6 +38,7 @@ module Configure = open System.Globalization open BitBadger.Documents.Postgres open Microsoft.AspNetCore.Authentication.Cookies + open Microsoft.AspNetCore.HttpOverrides open Microsoft.AspNetCore.Localization open Microsoft.Extensions.Caching.Distributed open Microsoft.Extensions.DependencyInjection @@ -56,6 +58,10 @@ module Configure = opts.DefaultRequestCulture <- RequestCulture("en-US", "en-US") opts.SupportedCultures <- supportedCultures opts.SupportedUICultures <- supportedCultures) + let _ = + svc.Configure( + fun (opts: ForwardedHeadersOptions) -> + opts.ForwardedHeaders <- ForwardedHeaders.XForwardedFor ||| ForwardedHeaders.XForwardedProto) let _ = svc.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(fun opts -> @@ -176,8 +182,6 @@ module Configure = logger.LogError(EventId(), ex, "An unhandled exception has occurred while executing the request.") clearResponse >=> setStatusCode 500 >=> text ex.Message - open Microsoft.Extensions.Hosting - /// Configure logging let logging (log: ILoggingBuilder) = let env = log.Services.BuildServiceProvider().GetService() @@ -190,9 +194,8 @@ module Configure = open Microsoft.Extensions.Options /// Configure the application - let app (app : IApplicationBuilder) = - let env = app.ApplicationServices.GetRequiredService() - if env.IsDevelopment() then + let app (app : WebApplication) = + if app.Environment.IsDevelopment() then app.UseDeveloperExceptionPage() else app.UseGiraffeErrorHandler errorHandler @@ -206,12 +209,11 @@ module Configure = let _ = app.UseMiddleware() let _ = app.UseRouting() let _ = app.UseSession() - let _ = app.UseRequestLocalization( - app.ApplicationServices.GetService>().Value) + let _ = app.UseRequestLocalization(app.Services.GetService>().Value) let _ = app.UseAuthentication() let _ = app.UseAuthorization() let _ = app.UseEndpoints(fun e -> e.MapGiraffeEndpoints routes) - app.ApplicationServices.GetRequiredService() |> Views.I18N.setUpFactories + app.Services.GetRequiredService() |> Views.I18N.setUpFactories /// The web application @@ -222,15 +224,19 @@ module App = [] let main args = let contentRoot = Directory.GetCurrentDirectory() - let app = - WebHostBuilder() - .UseContentRoot(contentRoot) - .ConfigureAppConfiguration(Configure.configuration) - .UseKestrel(Configure.kestrel) - .UseWebRoot(Path.Combine(contentRoot, "wwwroot")) - .ConfigureServices(Configure.services) - .ConfigureLogging(Configure.logging) - .Configure(System.Action Configure.app) - .Build() + let builder = WebApplication.CreateBuilder( + WebApplicationOptions( + ContentRootPath = contentRoot, + WebRootPath = Path.Combine(contentRoot, "wwwroot"), + Args = args)) + let _ = builder.Host.ConfigureAppConfiguration Configure.configuration + let _ = builder.WebHost.UseStaticWebAssets() + let _ = builder.WebHost.UseKestrel Configure.kestrel + let _ = Configure.services builder.Services + let _ = builder.WebHost.ConfigureLogging Configure.logging + + let app = builder.Build() + Configure.app app + if args.Length > 0 then printfn $"Unrecognized option {args[0]}" else app.Run() 0