Донастройка
This commit is contained in:
@@ -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" } } });
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user