This commit is contained in:
JavMB 2026-05-15 19:52:04 +02:00
parent 12b1755e86
commit 8fb5d801cf
3 changed files with 7 additions and 23 deletions

View File

@ -51,27 +51,14 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
builder.Services.AddAuthorization(); builder.Services.AddAuthorization();
// CORS: Allow all origins in dev, configurable in prod // CORS: Permitir cualquier origen (demo)
var corsOrigins = builder.Configuration["Cors:AllowedOrigins"];
builder.Services.AddCors(options => builder.Services.AddCors(options =>
{ {
options.AddPolicy("AllowVueApp", policy => options.AddPolicy("AllowVueApp", policy =>
{ {
if (string.IsNullOrEmpty(corsOrigins)) policy.AllowAnyOrigin()
{
policy.SetIsOriginAllowed(_ => true)
.AllowAnyMethod() .AllowAnyMethod()
.AllowAnyHeader() .AllowAnyHeader();
.AllowCredentials();
}
else
{
var origins = corsOrigins.Split(';', StringSplitOptions.RemoveEmptyEntries);
policy.WithOrigins(origins)
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials();
}
}); });
}); });

View File

@ -11,9 +11,6 @@
"ApiUrl": "http://localhost/api/index.php", "ApiUrl": "http://localhost/api/index.php",
"ApiKey": "" "ApiKey": ""
}, },
"Cors": {
"AllowedOrigins": ""
},
"Jwt": { "Jwt": {
"Secret": "", "Secret": "",
"Issuer": "DoliMiddleware", "Issuer": "DoliMiddleware",
@ -21,4 +18,5 @@
}, },
"Notifications": { "Notifications": {
"WebhookUrl": "" "WebhookUrl": ""
}} }
}

View File

@ -63,7 +63,6 @@
- ASPNETCORE_ENVIRONMENT=Production - ASPNETCORE_ENVIRONMENT=Production
- Jwt__Secret=DevDemoSecretKeyForDockerCompose2026Min32Chars!! - Jwt__Secret=DevDemoSecretKeyForDockerCompose2026Min32Chars!!
- Dolibarr__ApiUrl=http://dolibarr/api/index.php - Dolibarr__ApiUrl=http://dolibarr/api/index.php
- Cors__AllowedOrigins=http://localhost:3000;http://localhost:3001;http://localhost:5173;http://localhost:5269
restart: unless-stopped restart: unless-stopped
volumes: volumes: