Skip to content

Commit 00e0b50

Browse files
committed
fix(api): remove MapGroup and restore stable controller routing for logs
1 parent 1cbb150 commit 00e0b50

3 files changed

Lines changed: 21 additions & 12 deletions

File tree

DotnetDevopsPipeline.AdminUI/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// Add services to the container.
66
builder.Services.AddControllersWithViews();
77
builder.Services.AddHttpClient<DashboardApiService>();
8-
builder.Services.AddHttpClient<DashboardApiService>();
98
builder.Services.AddHttpClient<LogsApiService>();
109

1110
var app = builder.Build();

DotnetDevopsPipeline.AdminUI/Services/LogsApiService.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,28 @@ public class LogsApiService
1010
public LogsApiService(HttpClient httpClient)
1111
{
1212
_httpClient = httpClient;
13+
14+
// ✅ PROD API BASE ADDRESS
15+
_httpClient.BaseAddress = new Uri("https://dotnet-devops-pipeline.onrender.com/");
1316
}
1417

1518
public async Task<List<string>> GetLogsAsync(int take = 200)
1619
{
17-
var url = $"https://dotnet-devops-pipeline.onrender.com/api/v1/logs?take={take}";
18-
var response = await _httpClient.GetFromJsonAsync<List<LogEntryDto>>(url);
20+
try
21+
{
22+
var url = $"api/v1/logs?take={take}";
23+
var response = await _httpClient.GetFromJsonAsync<List<LogEntryDto>>(url);
1924

20-
return response?.Select(x => x.Raw).ToList() ?? new List<string>();
25+
return response?.Select(x => x.Raw).ToList() ?? new List<string>();
26+
}
27+
catch
28+
{
29+
// ✅ 404, bağlantı hatası vs. UI’yi patlatmasın
30+
return new List<string>
31+
{
32+
"API log endpoint erişilemedi (404 veya bağlantı hatası)."
33+
};
34+
}
2135
}
2236

2337
public class LogEntryDto

DotnetDevopsPipeline.Api/Program.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@
2626
app.UseHttpsRedirection();
2727
app.UseAuthorization();
2828

29-
// ✅ API v1 route group
30-
var v1 = app.MapGroup("/api/v1");
31-
32-
v1.MapControllers();
33-
v1.MapHealthChecks("/health");
34-
35-
// ✅ ROOT health endpoint (Render ve dış sistemler için ZORUNLU)
36-
app.MapHealthChecks("/health");
29+
// ✅ KRİTİK DÜZELTME — GROUP KULLANMIYORUZ
30+
app.MapControllers(); // /api/v1/logs artık %100 çalışacak
31+
app.MapHealthChecks("/api/v1/health"); // versiyonlu health
32+
app.MapHealthChecks("/health"); // root health (Render için)
3733

3834
app.Run();

0 commit comments

Comments
 (0)