diff --git a/src/Tgstation.Server.Host/Core/ServerPortProivder.cs b/src/Tgstation.Server.Host/Core/ServerPortProivder.cs index 0b97105c43..a3f39a4ab8 100644 --- a/src/Tgstation.Server.Host/Core/ServerPortProivder.cs +++ b/src/Tgstation.Server.Host/Core/ServerPortProivder.cs @@ -7,8 +7,6 @@ using Microsoft.Extensions.Options; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Core { /// @@ -36,18 +34,17 @@ namespace Tgstation.Server.Host.Core generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); ArgumentNullException.ThrowIfNull(configuration); + var usingDefaultPort = generalConfiguration.ApiPort == default; + if (!usingDefaultPort) + return; + var httpEndpoint = configuration .GetSection("Kestrel") .GetSection("EndPoints") .GetSection("Http") .GetSection("Url") - .Value; - - if (generalConfiguration.ApiPort == default && httpEndpoint == null) - throw new InvalidOperationException("Missing required configuration option General:ApiPort!"); - - if (generalConfiguration.ApiPort != default) - return; + .Value + ?? throw new InvalidOperationException("Missing required configuration option General:ApiPort!"); logger.LogWarning("The \"Kestrel\" configuration section is deprecated! Please set your API port using the \"General:ApiPort\" configuration option!");