From d92dd7ea3b0ef98409733d9e0ae1d971370cb96c Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 18 Jan 2022 18:50:59 +0100 Subject: [PATCH] Add support for avif (#1812) --- util/Server/Startup.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/util/Server/Startup.cs b/util/Server/Startup.cs index 467dfd620..4c328e12c 100644 --- a/util/Server/Startup.cs +++ b/util/Server/Startup.cs @@ -3,6 +3,7 @@ using System.Globalization; using System.Linq; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.StaticFiles; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -49,12 +50,16 @@ namespace Bit.Server } else if (configuration.GetValue("webVault") ?? false) { + // TODO: This should be removed when asp.net natively support avif + var provider = new FileExtensionContentTypeProvider { Mappings = { [".avif"] = "image/avif" } }; + var options = new DefaultFilesOptions(); options.DefaultFileNames.Clear(); options.DefaultFileNames.Add("index.html"); app.UseDefaultFiles(options); app.UseStaticFiles(new StaticFileOptions { + ContentTypeProvider = provider, OnPrepareResponse = ctx => { if (!ctx.Context.Request.Path.HasValue ||