From 166c7cab71cbd1fd448cd3718b80e2f4495f1876 Mon Sep 17 00:00:00 2001 From: "Eric J. Smith" Date: Wed, 4 Nov 2026 13:34:43 -0600 Subject: [PATCH 1/5] Fix Helm chart defaults: service names, storage mounts, storage class, migration schedule (#2695) --- k8s/ex-dev-values.yaml | 3 +++ k8s/ex-prod-values.yaml | 3 +++ k8s/exceptionless/templates/config.yaml | 4 ++-- k8s/exceptionless/templates/jobs.yaml | 30 +++++++++++++++++++++++- k8s/exceptionless/templates/storage.yaml | 10 +++++--- k8s/exceptionless/values.yaml | 8 +++++++ 6 files changed, 52 insertions(+), 6 deletions(-) diff --git a/k8s/ex-dev-values.yaml b/k8s/ex-dev-values.yaml index 341471ab7d..0905473a0d 100644 --- a/k8s/ex-dev-values.yaml +++ b/k8s/ex-dev-values.yaml @@ -21,6 +21,9 @@ jobs: image: repository: exceptionless/job-ci +storage: + storageClassName: managed-csi-premium + config: # Public client-scoped ingestion key for the hosted-dev Exceptionless project. EX_ExceptionlessApiKey: "sdyW9LA7y2MbRGkdwTV8Ufdqw2250O0LGZuW1nV4" diff --git a/k8s/ex-prod-values.yaml b/k8s/ex-prod-values.yaml index c46a23cdc3..53ea6f2a23 100644 --- a/k8s/ex-prod-values.yaml +++ b/k8s/ex-prod-values.yaml @@ -31,6 +31,9 @@ jobs: minReplicaCount: 2 maxReplicaCount: 5 +storage: + storageClassName: managed-csi-premium + config: EX_ClientSetupShowServerUrl: "false" EX_EnableSnapshotJobs: "true" diff --git a/k8s/exceptionless/templates/config.yaml b/k8s/exceptionless/templates/config.yaml index 2823ac70bc..bef5fed165 100644 --- a/k8s/exceptionless/templates/config.yaml +++ b/k8s/exceptionless/templates/config.yaml @@ -30,9 +30,9 @@ data: EX_ForwardedHeaders__KnownNetworks__{{ $index }}: {{ $network | quote }} {{- end }} {{- end }} - EX_ConnectionStrings__Elasticsearch: {{ default "server=http://elasticsearch:9200" .Values.elasticsearch.connectionString }} + EX_ConnectionStrings__Elasticsearch: {{ default (printf "server=http://%s-elasticsearch:9200" (include "exceptionless.fullname" .)) .Values.elasticsearch.connectionString }} {{- if (empty .Values.redis.connectionString) }} - EX_ConnectionStrings__Redis: {{ template "exceptionless.fullname" . }}-redis-master,abortConnect=false + EX_ConnectionStrings__Redis: {{ template "exceptionless.fullname" . }}-redis,abortConnect=false {{- else }} EX_ConnectionStrings__Redis: {{ .Values.redis.connectionString }} {{- end }} diff --git a/k8s/exceptionless/templates/jobs.yaml b/k8s/exceptionless/templates/jobs.yaml index 3a71d1a8ae..f8c2822e33 100644 --- a/k8s/exceptionless/templates/jobs.yaml +++ b/k8s/exceptionless/templates/jobs.yaml @@ -216,6 +216,15 @@ spec: fieldRef: fieldPath: metadata.uid {{- include "exceptionless.otel-env" . | indent 16 }} +{{- if (empty .Values.storage.connectionString) }} + volumeMounts: + - mountPath: "/app/storage" + name: storage + volumes: + - name: storage + persistentVolumeClaim: + claimName: {{ template "exceptionless.fullname" . }}-storage +{{- end }} restartPolicy: OnFailure --- @@ -381,6 +390,15 @@ spec: fieldRef: fieldPath: metadata.uid {{- include "exceptionless.otel-env" . | indent 12 }} +{{- if (empty .Values.storage.connectionString) }} + volumeMounts: + - mountPath: "/app/storage" + name: storage + volumes: + - name: storage + persistentVolumeClaim: + claimName: {{ template "exceptionless.fullname" . }}-storage +{{- end }} {{- if not (kindIs "invalid" ( .Values.jobs.eventPosts | default dict ).maxReplicaCount) }} --- @@ -417,7 +435,8 @@ metadata: release: {{ .Release.Name }} heritage: {{ .Release.Service }} spec: - schedule: "0 0 29 2 1" # never, only manually + schedule: "0 0 29 2 1" # never, only manually (create a job with kubectl) + suspend: true concurrencyPolicy: Forbid jobTemplate: spec: @@ -730,6 +749,15 @@ spec: fieldRef: fieldPath: metadata.uid {{- include "exceptionless.otel-env" . | indent 16 }} +{{- if (empty .Values.storage.connectionString) }} + volumeMounts: + - mountPath: "/app/storage" + name: storage + volumes: + - name: storage + persistentVolumeClaim: + claimName: {{ template "exceptionless.fullname" . }}-storage +{{- end }} restartPolicy: OnFailure --- diff --git a/k8s/exceptionless/templates/storage.yaml b/k8s/exceptionless/templates/storage.yaml index fe9e1fb100..83a1943cdd 100644 --- a/k8s/exceptionless/templates/storage.yaml +++ b/k8s/exceptionless/templates/storage.yaml @@ -5,10 +5,14 @@ metadata: name: {{ template "exceptionless.fullname" . }}-storage spec: accessModes: - - ReadWriteMany - storageClassName: managed-csi-premium + {{- range (.Values.storage.accessModes | default (list "ReadWriteMany")) }} + - {{ . }} + {{- end }} + {{- if .Values.storage.storageClassName }} + storageClassName: {{ .Values.storage.storageClassName }} + {{- end }} resources: requests: - storage: 5Gi + storage: {{ .Values.storage.size | default "5Gi" }} {{- end -}} \ No newline at end of file diff --git a/k8s/exceptionless/values.yaml b/k8s/exceptionless/values.yaml index dc37340412..e387827d0f 100644 --- a/k8s/exceptionless/values.yaml +++ b/k8s/exceptionless/values.yaml @@ -53,6 +53,14 @@ redis: storage: connectionString: + # Used for the folder storage claim when no connectionString is set. Leave + # storageClassName empty to use the cluster default. Pods on more than one node + # need a ReadWriteMany capable class (NFS, Azure Files, EFS) or an object + # storage connectionString. + storageClassName: + accessModes: + - ReadWriteMany + size: 5Gi cache: connectionString: From 6adeb9e6d087c665d8ac5a1e2ef58c07ab2ca487 Mon Sep 17 00:00:00 2001 From: "Eric J. Smith" Date: Wed, 4 Nov 2026 13:35:39 -0600 Subject: [PATCH 2/5] Fix smtps:// connection string defaulting to port 25 without TLS (#2697) --- .../Configuration/EmailOptions.cs | 10 ++++++++-- src/Exceptionless.Core/Utility/SmtpUri.cs | 1 - tests/Exceptionless.Tests/Mail/MailerTests.cs | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Exceptionless.Core/Configuration/EmailOptions.cs b/src/Exceptionless.Core/Configuration/EmailOptions.cs index 24e3f9268c..bd15ab1400 100644 --- a/src/Exceptionless.Core/Configuration/EmailOptions.cs +++ b/src/Exceptionless.Core/Configuration/EmailOptions.cs @@ -43,6 +43,7 @@ public static EmailOptions ReadFromConfiguration(IConfiguration config, AppOptio options.TestEmailAddress = config.GetValue(nameof(options.TestEmailAddress), appOptions.AppMode == AppMode.Development ? "admin@exceptionless.test" : null); options.ContactEmailAddress = config.GetValue(nameof(options.ContactEmailAddress)); + bool isSecure = false; string? emailConnectionString = config.GetConnectionString("Email"); if (!String.IsNullOrEmpty(emailConnectionString)) { @@ -51,10 +52,11 @@ public static EmailOptions ReadFromConfiguration(IConfiguration config, AppOptio options.SmtpPort = uri.Port; options.SmtpUser = uri.User; options.SmtpPassword = uri.Password; + isSecure = uri.IsSecure; } options.SmtpFrom = config.GetValue(nameof(options.SmtpFrom), appOptions.AppMode == AppMode.Development ? "Exceptionless " : null); - options.SmtpEncryption = config.GetValue(nameof(options.SmtpEncryption), GetDefaultSmtpEncryption(options.SmtpPort)); + options.SmtpEncryption = config.GetValue(nameof(options.SmtpEncryption), GetDefaultSmtpEncryption(options.SmtpPort, isSecure)); if (String.IsNullOrWhiteSpace(options.SmtpUser) != String.IsNullOrWhiteSpace(options.SmtpPassword)) throw new ArgumentException("Must specify both the SmtpUser and the SmtpPassword, or neither."); @@ -62,8 +64,12 @@ public static EmailOptions ReadFromConfiguration(IConfiguration config, AppOptio return options; } - private static SmtpEncryption GetDefaultSmtpEncryption(int port) + private static SmtpEncryption GetDefaultSmtpEncryption(int port, bool isSecure) { + // The smtps scheme always selects TLS: implicit on 465, STARTTLS on other ports. + if (isSecure && port != 465) + return SmtpEncryption.StartTLS; + return port switch { 465 => SmtpEncryption.SSL, diff --git a/src/Exceptionless.Core/Utility/SmtpUri.cs b/src/Exceptionless.Core/Utility/SmtpUri.cs index 6a1a1ae70c..4488245385 100644 --- a/src/Exceptionless.Core/Utility/SmtpUri.cs +++ b/src/Exceptionless.Core/Utility/SmtpUri.cs @@ -38,7 +38,6 @@ public SmtpUri(Uri uri) } Host = uri.Host; - Port = uri.IsDefaultPort ? 25 : uri.Port; } public string Host { get; } diff --git a/tests/Exceptionless.Tests/Mail/MailerTests.cs b/tests/Exceptionless.Tests/Mail/MailerTests.cs index 9aa950e99c..eacca00bf4 100644 --- a/tests/Exceptionless.Tests/Mail/MailerTests.cs +++ b/tests/Exceptionless.Tests/Mail/MailerTests.cs @@ -73,6 +73,20 @@ public void Constructor_WithSecureSmtpUri_ParsesComponents() Assert.Equal("testpass", uri.Password); } + [Theory] + [InlineData("smtp://smtp.test.com", 25, false)] + [InlineData("smtps://smtp.test.com", 465, true)] + [InlineData("smtps://smtp.test.com:587", 587, true)] + public void Constructor_WithOrWithoutPort_UsesSchemeDefaultPort(string value, int expectedPort, bool expectedSecure) + { + // Arrange & Act + var uri = new SmtpUri(value); + + // Assert + Assert.Equal(expectedPort, uri.Port); + Assert.Equal(expectedSecure, uri.IsSecure); + } + [Theory] [InlineData("http://localhost:9001", "http://localhost:9001/organization/organization-1/billing")] [InlineData("http://localhost:9001/#!", "http://localhost:9001/organization/organization-1/billing")] From 76ebd4c24bf29cd682a5502aa1d6a4f045bbffb6 Mon Sep 17 00:00:00 2001 From: "Eric J. Smith" Date: Wed, 4 Nov 2026 13:41:36 -0600 Subject: [PATCH 3/5] Fix OpenAPI docs for identity.name and token scopes (#2707) --- .../Api/Endpoints/EventEndpoints.cs | 10 ++++----- .../Api/Endpoints/TokenEndpoints.cs | 6 ++--- .../Exceptionless.Tests/Api/Data/openapi.json | 22 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Exceptionless.Web/Api/Endpoints/EventEndpoints.cs b/src/Exceptionless.Web/Api/Endpoints/EventEndpoints.cs index 26ab7a1726..f2b0e31d51 100644 --- a/src/Exceptionless.Web/Api/Endpoints/EventEndpoints.cs +++ b/src/Exceptionless.Web/Api/Endpoints/EventEndpoints.cs @@ -607,7 +607,7 @@ public static IEndpointRouteBuilder MapEventEndpoints(this IEndpointRouteBuilder ["geo"] = "The geo coordinates where the event happened.", ["tags"] = "A list of tags used to categorize this event (comma separated).", ["identity"] = "The user's identity that the event happened to.", - ["identityname"] = "The user's friendly name that the event happened to.", + ["identity.name"] = "The user's friendly name that the event happened to.", ["userAgent"] = "The user agent that submitted the event.", ["parameters"] = "Query string parameters that control what properties are set on the event", }, @@ -647,7 +647,7 @@ public static IEndpointRouteBuilder MapEventEndpoints(this IEndpointRouteBuilder ["geo"] = "The geo coordinates where the event happened.", ["tags"] = "A list of tags used to categorize this event (comma separated).", ["identity"] = "The user's identity that the event happened to.", - ["identityname"] = "The user's friendly name that the event happened to.", + ["identity.name"] = "The user's friendly name that the event happened to.", ["userAgent"] = "The user agent that submitted the event.", ["parameters"] = "Query string parameters that control what properties are set on the event", }, @@ -679,7 +679,7 @@ public static IEndpointRouteBuilder MapEventEndpoints(this IEndpointRouteBuilder ["geo"] = "The geo coordinates where the event happened.", ["tags"] = "A list of tags used to categorize this event (comma separated).", ["identity"] = "The user's identity that the event happened to.", - ["identityname"] = "The user's friendly name that the event happened to.", + ["identity.name"] = "The user's friendly name that the event happened to.", ["userAgent"] = "The user agent that submitted the event.", ["parameters"] = "Query String parameters that control what properties are set on the event", }, @@ -712,7 +712,7 @@ public static IEndpointRouteBuilder MapEventEndpoints(this IEndpointRouteBuilder ["geo"] = "The geo coordinates where the event happened.", ["tags"] = "A list of tags used to categorize this event (comma separated).", ["identity"] = "The user's identity that the event happened to.", - ["identityname"] = "The user's friendly name that the event happened to.", + ["identity.name"] = "The user's friendly name that the event happened to.", ["userAgent"] = "The user agent that submitted the event.", ["parameters"] = "Query String parameters that control what properties are set on the event", }, @@ -920,7 +920,7 @@ internal static class EventEndpointHelpers new("geo", "query", Description: "The geo coordinates where the event happened."), new("tags", "query", Description: "A list of tags used to categorize this event (comma separated)."), new("identity", "query", Description: "The user's identity that the event happened to."), - new("identityname", "query", Description: "The user's friendly name that the event happened to."), + new("identity.name", "query", Description: "The user's friendly name that the event happened to."), new("userAgent", "header", Description: "The user agent that submitted the event."), new("parameters", "query", Description: "Query string parameters that control what properties are set on the event", Type: "array"), ]; diff --git a/src/Exceptionless.Web/Api/Endpoints/TokenEndpoints.cs b/src/Exceptionless.Web/Api/Endpoints/TokenEndpoints.cs index 36bf374960..50cc13e5f7 100644 --- a/src/Exceptionless.Web/Api/Endpoints/TokenEndpoints.cs +++ b/src/Exceptionless.Web/Api/Endpoints/TokenEndpoints.cs @@ -98,7 +98,7 @@ public static IEndpointRouteBuilder MapTokenEndpoints(this IEndpointRouteBuilder .ProducesProblem(StatusCodes.Status400BadRequest) .ProducesProblem(StatusCodes.Status409Conflict) .WithSummary("Create") - .WithDescription("To create a new token, you must specify an organization_id and project_id. Valid scopes are client, user, admin, and source-maps:write. The source-maps:write scope requires a project-scoped token.") + .WithDescription("To create a new token, you must specify an organization_id and project_id. Valid scopes are client, user, global (global administrators only), and source-maps:write. The source-maps:write scope requires a project-scoped token.") .WithMetadata(new EndpointDocumentation { RequestBodyDescription = "The token.", ResponseDescriptions = new() { @@ -119,7 +119,7 @@ public static IEndpointRouteBuilder MapTokenEndpoints(this IEndpointRouteBuilder .ProducesProblem(StatusCodes.Status404NotFound) .ProducesProblem(StatusCodes.Status409Conflict) .WithSummary("Create for project") - .WithDescription("This is a helper action that makes it easier to create a token for a specific project. Valid scopes are client, user, admin, and source-maps:write.") + .WithDescription("This is a helper action that makes it easier to create a token for a specific project. Valid scopes are client, user, global (global administrators only), and source-maps:write.") .WithMetadata(new EndpointDocumentation { RequestBodyDescription = "The token.", ParameterDescriptions = new() { @@ -143,7 +143,7 @@ public static IEndpointRouteBuilder MapTokenEndpoints(this IEndpointRouteBuilder .ProducesProblem(StatusCodes.Status400BadRequest) .ProducesProblem(StatusCodes.Status409Conflict) .WithSummary("Create for organization") - .WithDescription("This is a helper action that makes it easier to create a token for a specific organization. You may also specify a scope when creating a token. There are three valid scopes: client, user and admin.") + .WithDescription("This is a helper action that makes it easier to create a token for a specific organization. You may also specify a scope when creating a token. Valid scopes are client, user and global (global administrators only).") .WithMetadata(new EndpointDocumentation { RequestBodyDescription = "The token.", ParameterDescriptions = new() { diff --git a/tests/Exceptionless.Tests/Api/Data/openapi.json b/tests/Exceptionless.Tests/Api/Data/openapi.json index 88be9cf072..992f9dc617 100644 --- a/tests/Exceptionless.Tests/Api/Data/openapi.json +++ b/tests/Exceptionless.Tests/Api/Data/openapi.json @@ -732,7 +732,7 @@ } }, { - "name": "identityname", + "name": "identity.name", "in": "query", "description": "The user\u0027s friendly name that the event happened to.", "schema": { @@ -903,7 +903,7 @@ } }, { - "name": "identityname", + "name": "identity.name", "in": "query", "description": "The user\u0027s friendly name that the event happened to.", "schema": { @@ -1074,7 +1074,7 @@ } }, { - "name": "identityname", + "name": "identity.name", "in": "query", "description": "The user\u0027s friendly name that the event happened to.", "schema": { @@ -1254,7 +1254,7 @@ } }, { - "name": "identityname", + "name": "identity.name", "in": "query", "description": "The user\u0027s friendly name that the event happened to.", "schema": { @@ -2176,7 +2176,7 @@ "Token" ], "summary": "Create for organization", - "description": "This is a helper action that makes it easier to create a token for a specific organization. You may also specify a scope when creating a token. There are three valid scopes: client, user and admin.", + "description": "This is a helper action that makes it easier to create a token for a specific organization. You may also specify a scope when creating a token. Valid scopes are client, user and global (global administrators only).", "parameters": [ { "name": "organizationId", @@ -2321,7 +2321,7 @@ "Token" ], "summary": "Create for project", - "description": "This is a helper action that makes it easier to create a token for a specific project. Valid scopes are client, user, admin, and source-maps:write.", + "description": "This is a helper action that makes it easier to create a token for a specific project. Valid scopes are client, user, global (global administrators only), and source-maps:write.", "parameters": [ { "name": "projectId", @@ -2630,7 +2630,7 @@ "Token" ], "summary": "Create", - "description": "To create a new token, you must specify an organization_id and project_id. Valid scopes are client, user, admin, and source-maps:write. The source-maps:write scope requires a project-scoped token.", + "description": "To create a new token, you must specify an organization_id and project_id. Valid scopes are client, user, global (global administrators only), and source-maps:write. The source-maps:write scope requires a project-scoped token.", "requestBody": { "description": "The token.", "content": { @@ -10876,7 +10876,7 @@ } }, { - "name": "identityname", + "name": "identity.name", "in": "query", "description": "The user\u0027s friendly name that the event happened to.", "schema": { @@ -11049,7 +11049,7 @@ } }, { - "name": "identityname", + "name": "identity.name", "in": "query", "description": "The user\u0027s friendly name that the event happened to.", "schema": { @@ -11229,7 +11229,7 @@ } }, { - "name": "identityname", + "name": "identity.name", "in": "query", "description": "The user\u0027s friendly name that the event happened to.", "schema": { @@ -11412,7 +11412,7 @@ } }, { - "name": "identityname", + "name": "identity.name", "in": "query", "description": "The user\u0027s friendly name that the event happened to.", "schema": { From cf31e0db5b43fb33e28f4d84483bee99dc2f4ae4 Mon Sep 17 00:00:00 2001 From: "Eric J. Smith" Date: Wed, 4 Nov 2026 13:41:36 -0600 Subject: [PATCH 4/5] Drop email from late user descriptions when private information is removed (#2693) --- .../Api/Handlers/EventHandler.cs | 4 ++- .../Api/Endpoints/EventEndpointTests.cs | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/Exceptionless.Web/Api/Handlers/EventHandler.cs b/src/Exceptionless.Web/Api/Handlers/EventHandler.cs index 1b9a8f4029..851dc68b2a 100644 --- a/src/Exceptionless.Web/Api/Handlers/EventHandler.cs +++ b/src/Exceptionless.Web/Api/Handlers/EventHandler.cs @@ -362,11 +362,13 @@ public async Task Handle(SetEventUserDescription message) // Set the project for the configuration response filter. httpContext.Request.SetProject(project); + // Match RemovePrivateInformationPlugin: drop the email address when private information is not collected. + bool includePrivateInformation = project.Configuration.Settings.GetBoolean(SettingsDictionary.KnownKeys.IncludePrivateInformation, true); var eventUserDescription = new EventUserDescription { ProjectId = project.Id, ReferenceId = message.ReferenceId, - EmailAddress = message.Description.EmailAddress, + EmailAddress = includePrivateInformation ? message.Description.EmailAddress : null, Description = message.Description.Description, Data = message.Description.Data }; diff --git a/tests/Exceptionless.Tests/Api/Endpoints/EventEndpointTests.cs b/tests/Exceptionless.Tests/Api/Endpoints/EventEndpointTests.cs index f46babddc4..cae98348d0 100644 --- a/tests/Exceptionless.Tests/Api/Endpoints/EventEndpointTests.cs +++ b/tests/Exceptionless.Tests/Api/Endpoints/EventEndpointTests.cs @@ -420,6 +420,37 @@ await SendRequestAsync(r => r Assert.Equal(TestConstants.UserEmail, description.EmailAddress); } + [Theory] + [InlineData(false, null)] + [InlineData(true, TestConstants.UserEmail)] + public async Task PostUserDescription_WithIncludePrivateInformationSetting_QueuesExpectedEmailAddressAsync(bool includePrivateInformation, string? expectedEmailAddress) + { + // Arrange + var project = await _projectRepository.GetByIdAsync(TestConstants.ProjectId); + Assert.NotNull(project); + project.Configuration.Settings[SettingsDictionary.KnownKeys.IncludePrivateInformation] = includePrivateInformation.ToString(); + await _projectRepository.SaveAsync(project, o => o.ImmediateConsistency().Cache()); + await _eventUserDescriptionQueue.DeleteQueueAsync(); + + // Act + await SendRequestAsync(r => r + .Post() + .AsTestOrganizationClientUser() + .AppendPath("events/by-ref/TestReferenceId/user-description") + .Content(new UserDescription { Description = "Test Description", EmailAddress = TestConstants.UserEmail }) + .StatusCodeShouldBeAccepted() + ); + + // Assert + var entry = await _eventUserDescriptionQueue.DequeueAsync(TestCancellationToken); + Assert.NotNull(entry); + Assert.Equal(expectedEmailAddress, entry.Value.EmailAddress); + Assert.Equal("Test Description", entry.Value.Description); + + await entry.AbandonAsync(); + await _eventUserDescriptionQueue.DeleteQueueAsync(); + } + [Fact] public async Task PostEvent_WithNoMatchingEvent_UserDescriptionIsAbandonedAsync() { From 6c7467eadf835310e15067fc42898f1dfb371e5e Mon Sep 17 00:00:00 2001 From: "Eric J. Smith" Date: Wed, 4 Nov 2026 13:41:36 -0600 Subject: [PATCH 5/5] Enable HTTPS redirection outside Development (#2694) --- src/Exceptionless.Web/Program.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Exceptionless.Web/Program.cs b/src/Exceptionless.Web/Program.cs index f0de9e65ae..3c79dc40f3 100644 --- a/src/Exceptionless.Web/Program.cs +++ b/src/Exceptionless.Web/Program.cs @@ -268,10 +268,9 @@ ApplicationException applicationException when applicationException.Message.Cont await next(); }); - var serverAddressesFeature = app.Services.GetRequiredService().Features.Get(); - bool ssl = options.AppMode != AppMode.Development && serverAddressesFeature is not null && serverAddressesFeature.Addresses.Any(a => a.StartsWith("https://")); - - if (ssl) + // Resolves the HTTPS port lazily on the first request (HTTPS_PORT or the bound https addresses) + // and does nothing when there is no HTTPS endpoint. Server addresses are not known until startup. + if (options.AppMode != AppMode.Development) app.UseHttpsRedirection(); var frontendOptions = app.Services.GetRequiredService();