Skip to content

Commit f41b61a

Browse files
authored
Merge pull request #26 from SMan0103/use-http
update so we can use http if no certfile are there
2 parents c56c78b + d837721 commit f41b61a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

backend/Program.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
HightlyFootballServiceTest test = new HightlyFootballServiceTest(httpClient, configuration);
4646
await test.TestPlayerStats();
4747

48+
// Track whether HTTPS is enabled
49+
bool isHttpsEnabled = false;
50+
4851
builder.WebHost.ConfigureKestrel(options =>
4952
{
5053
options.ListenAnyIP(5000, listenOptions =>
@@ -61,10 +64,12 @@
6164
if (File.Exists(certificatePath))
6265
{
6366
listenOptions.UseHttps(certificatePath, certificatePassword);
67+
isHttpsEnabled = true;
68+
Console.WriteLine("✅ HTTPS enabled with certificate.");
6469
}
6570
else
6671
{
67-
Console.WriteLine($"⚠️ Certificate file not found at {certificatePath}. Running without HTTPS.");
72+
Console.WriteLine($"⚠️ Certificate file not found at {certificatePath}. Running HTTP only.");
6873
}
6974
}
7075
else
@@ -96,7 +101,8 @@
96101
app.MapControllers();
97102

98103
Console.WriteLine("================================");
99-
Console.WriteLine("Backend server is running on https://localhost:5000");
104+
string protocol = isHttpsEnabled ? "https" : "http";
105+
Console.WriteLine($"Backend server is running on {protocol}://localhost:5000");
100106
Console.WriteLine("✅ Test completed. Press any key to exit...");
101107
app.Run();
102108
Console.ReadKey();

0 commit comments

Comments
 (0)