Донастройка

This commit is contained in:
Халимов Рустам
2026-03-12 16:24:21 +03:00
parent 782506ccc3
commit 09d0906cbd
3 changed files with 22 additions and 16 deletions

View File

@@ -1,16 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
namespace Vortex.Host.Controllers;
[Authorize]
[ApiController]
[Route("api/ice-servers")]
public sealed class IceServersController : ControllerBase
{
[HttpGet]
public IActionResult GetIceServers()
{
return Ok(new { iceServers = new List<object> { new { urls = "stun:stun.l.google.com:19302" } } });
}
}

View File

@@ -39,6 +39,25 @@ builder.Services.AddIdentityModule(builder.Configuration);
builder.Services.AddChatsModule(builder.Configuration);
builder.Services.AddSharedInfrastructure();
// Настройка CORS
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
var originsFromConfig = builder.Configuration["Cors:Origins"];
var domain = builder.Configuration["DOMAIN"];
var origins = !string.IsNullOrEmpty(originsFromConfig)
? originsFromConfig.Split(',')
: (!string.IsNullOrEmpty(domain) ? new[] { $"https://{domain}" } : new[] { "*" });
policy.WithOrigins(origins)
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
// Настройка Swagger/OpenAPI
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
@@ -112,6 +131,8 @@ using (var scope = app.Services.CreateScope())
// Настройка конвейера запросов
app.UseMiddleware<Vortex.Shared.Infrastructure.Middleware.ExceptionHandlingMiddleware>();
app.UseCors();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();

View File

@@ -20,6 +20,7 @@ services:
restart: always
environment:
DATABASE_URL: ${DATABASE_URL}
DOMAIN: ${DOMAIN}
JWT_SECRET: ${JWT_SECRET}
JWT_ISSUER: ${JWT_ISSUER}
JWT_AUDIENCE: ${JWT_AUDIENCE}