fix: update CORS configuration to include additional origin

This commit is contained in:
javiermengual 2026-01-16 19:07:40 +01:00
parent 72b15eeff6
commit 8c781308e7
1 changed files with 19 additions and 16 deletions

View File

@ -1,12 +1,12 @@
using System.Text;
using DoliMiddlewareApi.Exceptions; using DoliMiddlewareApi.Exceptions;
using DoliMiddlewareApi.Services; using DoliMiddlewareApi.Services;
using DoliMiddlewareApi.Services.Clients;
using DoliMiddlewareApi.Services.Auth; using DoliMiddlewareApi.Services.Auth;
using DoliMiddlewareApi.Services.Clients;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using System.Text;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.AspNetCore.Diagnostics; using Microsoft.AspNetCore.Diagnostics;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.IdentityModel.Tokens;
// ========================================= // =========================================
// PROGRAM.CS - CONFIGURACIÓN Y DEPENDENCIAS // PROGRAM.CS - CONFIGURACIÓN Y DEPENDENCIAS
@ -45,20 +45,23 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
}; };
}); });
builder.Services.AddAuthorization(); builder.Services.AddAuthorization();
// CORS Configuration // CORS Configuration
builder.Services.AddCors(options => builder.Services.AddCors(options =>
{ {
options.AddPolicy("AllowVueApp", options.AddPolicy("AllowVueApp",
policy => policy policy => policy
.WithOrigins("http://localhost:3001", "http://localhost:3000") .WithOrigins(
"http://localhost:3001",
"http://localhost:3000",
"http://localhost:5173")
.AllowAnyMethod() .AllowAnyMethod()
.AllowAnyHeader() .AllowAnyHeader()
.AllowCredentials()); .AllowCredentials());
}); });
// Swagger/OpenAPI // Swagger/OpenAPI
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(); builder.Services.AddSwaggerGen();