diff --git a/src/Api/Startup.cs b/src/Api/Startup.cs index 128b8deeae..85a0f5c652 100644 --- a/src/Api/Startup.cs +++ b/src/Api/Startup.cs @@ -148,9 +148,13 @@ namespace Bit.Api { config.Filters.Add(new ExceptionHandlerFilterAttribute()); config.Filters.Add(new ModelStateValidationFilterAttribute()); + // Allow JSON of content type "text/plain" to avoid cors preflight - config.InputFormatters.OfType().SingleOrDefault()? - .SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("text/plain")); + var textPlainMediaType = MediaTypeHeaderValue.Parse("text/plain"); + foreach(var jsonFormatter in config.InputFormatters.OfType()) + { + jsonFormatter.SupportedMediaTypes.Add(textPlainMediaType); + } }); }