From 6dc575222cbf09db0bcb7e5b228ec5bc1bab2a4b Mon Sep 17 00:00:00 2001 From: CoJaques Date: Thu, 22 Aug 2024 18:40:56 +0200 Subject: [PATCH 1/2] Add possibility to choose port from appconfig --- src/App/LionkApp/Program.cs | 10 ++++++++-- src/App/LionkApp/appsettings.json | 9 ++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/App/LionkApp/Program.cs b/src/App/LionkApp/Program.cs index f30d8c1f..7944bff6 100644 --- a/src/App/LionkApp/Program.cs +++ b/src/App/LionkApp/Program.cs @@ -21,8 +21,14 @@ WebApplicationBuilder builder = WebApplication.CreateBuilder(args); #if !DEBUG - // Configure Kestrel to listen on all IP addresses and port 5000 - builder.WebHost.UseKestrel(options => options.Listen(System.Net.IPAddress.Any, 5000)); +var httpsPort = builder.Configuration.GetValue("Kestrel:Endpoints:Https:Url")?.Split(':').Last() ?? 443; +builder.WebHost.UseKestrel(options => +{ + options.ListenAnyIP(int.Parse(httpsPort), listenOptions => + { + listenOptions.UseHttps(); + }); +}); #endif // Add services to the container. diff --git a/src/App/LionkApp/appsettings.json b/src/App/LionkApp/appsettings.json index 1304c23e..592fb7fd 100644 --- a/src/App/LionkApp/appsettings.json +++ b/src/App/LionkApp/appsettings.json @@ -6,5 +6,12 @@ } }, "AllowedHosts": "*", - "DetailedErrors" : true + "DetailedErrors": true, + "Kestrel": { + "Endpoints": { + "Https": { + "Url": "https://*:6001" // Replace 6001 with the port you want to use + } + } + } } From 531c668803ffeec014d68d192a999b24ed9de1ca Mon Sep 17 00:00:00 2001 From: CoJaques Date: Thu, 22 Aug 2024 20:59:04 +0200 Subject: [PATCH 2/2] Change default port --- src/App/LionkApp/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App/LionkApp/Program.cs b/src/App/LionkApp/Program.cs index 7944bff6..c0d5e114 100644 --- a/src/App/LionkApp/Program.cs +++ b/src/App/LionkApp/Program.cs @@ -21,7 +21,7 @@ WebApplicationBuilder builder = WebApplication.CreateBuilder(args); #if !DEBUG -var httpsPort = builder.Configuration.GetValue("Kestrel:Endpoints:Https:Url")?.Split(':').Last() ?? 443; +var httpsPort = builder.Configuration.GetValue("Kestrel:Endpoints:Https:Url")?.Split(':').Last() ?? 6001; builder.WebHost.UseKestrel(options => { options.ListenAnyIP(int.Parse(httpsPort), listenOptions =>