mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-03-04 14:27:52 -05:00
This commit is contained in:
@@ -42,6 +42,9 @@ public static class ApiDI
|
||||
|
||||
public static WebApplication ConfigureApi(this WebApplication app)
|
||||
{
|
||||
app.UseCors("SignalRPolicy");
|
||||
app.UseRouting();
|
||||
|
||||
// Configure middleware pipeline for API
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
@@ -59,8 +62,8 @@ public static class ApiDI
|
||||
app.MapControllers();
|
||||
|
||||
// Map SignalR hubs
|
||||
app.MapHub<HealthStatusHub>("/hubs/health");
|
||||
app.MapHub<LogHub>("/hubs/logs");
|
||||
app.MapHub<HealthStatusHub>("/api/hubs/health");
|
||||
app.MapHub<LogHub>("/api/hubs/logs");
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,18 @@ builder.Services
|
||||
.AddInfrastructure(builder.Configuration)
|
||||
.AddApiServices();
|
||||
|
||||
// Add CORS before SignalR
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("SignalRPolicy", policy =>
|
||||
{
|
||||
policy.WithOrigins("http://localhost:4200") // Your Angular URL
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod()
|
||||
.AllowCredentials(); // Required for SignalR auth
|
||||
});
|
||||
});
|
||||
|
||||
// Register SignalR - ensure this is before logging initialization
|
||||
builder.Services.AddSignalR();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user