fix CORS
This commit is contained in:
parent
12b1755e86
commit
8fb5d801cf
|
|
@ -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();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,12 @@
|
||||||
"ApiUrl": "http://localhost/api/index.php",
|
"ApiUrl": "http://localhost/api/index.php",
|
||||||
"ApiKey": ""
|
"ApiKey": ""
|
||||||
},
|
},
|
||||||
"Cors": {
|
|
||||||
"AllowedOrigins": ""
|
|
||||||
},
|
|
||||||
"Jwt": {
|
"Jwt": {
|
||||||
"Secret": "",
|
"Secret": "",
|
||||||
"Issuer": "DoliMiddleware",
|
"Issuer": "DoliMiddleware",
|
||||||
"Audience": "DoliClients"
|
"Audience": "DoliClients"
|
||||||
},
|
},
|
||||||
"Notifications":{
|
"Notifications": {
|
||||||
"WebhookUrl": ""
|
"WebhookUrl": ""
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
|
|
@ -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:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue