1. Удалена директива UseSpa из ConfigureServices

2. Считывание ip пользователя из заголовка "X-Real-IP"
This commit is contained in:
Olga Nemt 2023-11-07 14:02:04 +05:00
parent b90dcf8483
commit d8f4094d52
2 changed files with 3 additions and 7 deletions

View File

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Org.BouncyCastle.Asn1.Ocsp; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AsbCloudWebApi.Middlewares namespace AsbCloudWebApi.Middlewares
@ -18,10 +18,11 @@ namespace AsbCloudWebApi.Middlewares
public async Task InvokeAsync(HttpContext context) public async Task InvokeAsync(HttpContext context)
{ {
var service = context.RequestServices.GetRequiredService<AsbCloudApp.Services.IRequerstTrackerService>(); var service = context.RequestServices.GetRequiredService<AsbCloudApp.Services.IRequerstTrackerService>();
var clientIp = context.Request.Headers["X-Real-IP"].FirstOrDefault();
var requestLog = new AsbCloudApp.Data.RequestLogDto var requestLog = new AsbCloudApp.Data.RequestLogDto
{ {
UserLogin = context.User.Identity?.Name ?? string.Empty, UserLogin = context.User.Identity?.Name ?? string.Empty,
UserIp = context.Connection?.RemoteIpAddress?.ToString(), UserIp = clientIp ?? context.Connection?.RemoteIpAddress?.ToString(),
RequestMethod = context.Request.Method, RequestMethod = context.Request.Method,
RequestPath = context.Request.Path.Value, RequestPath = context.Request.Path.Value,
RequestContentLength = context.Request.ContentLength, RequestContentLength = context.Request.ContentLength,

View File

@ -158,11 +158,6 @@ namespace AsbCloudWebApi
endpoints.MapHub<TelemetryHub>("/hubs/telemetry"); endpoints.MapHub<TelemetryHub>("/hubs/telemetry");
endpoints.MapHub<ReportsHub>("/hubs/reports"); endpoints.MapHub<ReportsHub>("/hubs/reports");
}); });
app.UseSpa(spa =>
{
spa.Options.SourcePath = "wwwroot";
});
} }
} }
} }