fix CORS
This commit is contained in:
parent
12b1755e86
commit
8fb5d801cf
|
|
@ -51,27 +51,14 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|||
|
||||
builder.Services.AddAuthorization();
|
||||
|
||||
// CORS: Allow all origins in dev, configurable in prod
|
||||
var corsOrigins = builder.Configuration["Cors:AllowedOrigins"];
|
||||
// CORS: Permitir cualquier origen (demo)
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("AllowVueApp", policy =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(corsOrigins))
|
||||
{
|
||||
policy.SetIsOriginAllowed(_ => true)
|
||||
policy.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials();
|
||||
}
|
||||
else
|
||||
{
|
||||
var origins = corsOrigins.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
policy.WithOrigins(origins)
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials();
|
||||
}
|
||||
.AllowAnyHeader();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,6 @@
|
|||
"ApiUrl": "http://localhost/api/index.php",
|
||||
"ApiKey": ""
|
||||
},
|
||||
"Cors": {
|
||||
"AllowedOrigins": ""
|
||||
},
|
||||
"Jwt": {
|
||||
"Secret": "",
|
||||
"Issuer": "DoliMiddleware",
|
||||
|
|
@ -21,4 +18,5 @@
|
|||
},
|
||||
"Notifications": {
|
||||
"WebhookUrl": ""
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
|
@ -63,7 +63,6 @@
|
|||
- ASPNETCORE_ENVIRONMENT=Production
|
||||
- Jwt__Secret=DevDemoSecretKeyForDockerCompose2026Min32Chars!!
|
||||
- Dolibarr__ApiUrl=http://dolibarr/api/index.php
|
||||
- Cors__AllowedOrigins=http://localhost:3000;http://localhost:3001;http://localhost:5173;http://localhost:5269
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
|
|
|
|||
Loading…
Reference in New Issue