From a9d15790d59d00671b1166fdd3467abb1a0e8494 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Tue, 4 Mar 2025 09:33:01 -0800 Subject: [PATCH] feat: allow custom app-id.json location for rootless Co-authored-by: Justin Baur --- util/Server/Startup.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/util/Server/Startup.cs b/util/Server/Startup.cs index 7b195beb53..4eb84d2ad7 100644 --- a/util/Server/Startup.cs +++ b/util/Server/Startup.cs @@ -26,7 +26,8 @@ public class Startup public void Configure( IApplicationBuilder app, - IConfiguration configuration) + IConfiguration configuration, + ILogger logger) { if (configuration.GetValue("serveUnknown") ?? false) { @@ -44,6 +45,22 @@ public class Startup } else if (configuration.GetValue("webVault") ?? false) { + var appIdLocation = configuration.GetValue("appIdLocation"); + + if (!string.IsNullOrEmpty(appIdLocation)) + { + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapGet("/app-id.json", async context => + { + var appId = await File.ReadAllTextAsync(appIdLocation); + context.Response.ContentType = "application/json"; + await context.Response.WriteAsync(appId); + }); + }); + } + // TODO: This should be removed when asp.net natively support avif var provider = new FileExtensionContentTypeProvider { Mappings = { [".avif"] = "image/avif" } };