Skip to content

The Free Software Media System - Server Backend & API

Merge remote-tracking branch 'upstream/master' into access-control

ConfusedPolarBear3a61c9a87811
diff --cc Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
index 77878eacc9,0438122900..9554b9f462
--- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
@@@ -541,15 -496,19 +496,25 @@@ namespace Emby.Server.Implementations.H
{
var requestInnerEx = GetActualException(requestEx);
var statusCode = GetStatusCode(requestInnerEx);
+
+ if (!httpRes.Headers.ContainsKey("Access-Control-Allow-Origin"))
+ {
+ httpRes.Headers.Add("Access-Control-Allow-Origin", "*");
+ }
+
- // Do not handle 500 server exceptions manually when in development mode
- // The framework-defined development exception page will be returned instead
- if (statusCode == 500 && _hostEnvironment.IsDevelopment())
+ bool ignoreStackTrace =
+ requestInnerEx is SocketException
+ || requestInnerEx is IOException
+ || requestInnerEx is OperationCanceledException
+ || requestInnerEx is SecurityException
+ || requestInnerEx is AuthenticationException
+ || requestInnerEx is FileNotFoundException;
+
+ // Do not handle 500 server exceptions manually when in development mode.
+ // Instead, re-throw the exception so it can be handled by the DeveloperExceptionPageMiddleware.
+ // However, do not use the DeveloperExceptionPageMiddleware when the stack trace should be ignored,
+ // because it will log the stack trace when it handles the exception.
+ if (statusCode == 500 && !ignoreStackTrace && _hostEnvironment.IsDevelopment())
{
throw;
}