Skip to content

Commit

Permalink
introduce USE_DEV_HTTPS env var
Browse files Browse the repository at this point in the history
  • Loading branch information
rpardini committed Dec 4, 2023
1 parent 8db6d33 commit 60418bc
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions fluidsignalr/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ public static IHostBuilder CreateHostBuilder(string[] args)
webBuilder.UseKestrel(serverOptions =>
{
serverOptions.ListenAnyIP(5000);
try
{
serverOptions.ListenAnyIP(5001, options => { options.UseHttps(); });
}
catch (InvalidOperationException ignored)
{
Console.Out.WriteLine("Could not bind 5001: " + ignored.GetType().Name + ":" + ignored.Message);

// Only bind to 5001 if USE_DEV_HTTPS environment variable is set to "true"
if (bool.TryParse(Environment.GetEnvironmentVariable("USE_DEV_HTTPS"), out var useDevHttps) && useDevHttps) {
try
{
serverOptions.ListenAnyIP(5001, options => { options.UseHttps(); });
}
catch (InvalidOperationException ignored)
{
Console.Out.WriteLine("Could not bind 5001: " + ignored.GetType().Name + ":" + ignored.Message);
}
}
});
})
Expand Down

0 comments on commit 60418bc

Please sign in to comment.