Fix origini CORS su file di configurazione
This commit is contained in:
@@ -10,15 +10,14 @@ namespace PizzaExpress
|
|||||||
var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
|
var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
var allowedOrigins = builder.Configuration.GetSection("AllowedOrigins").Get<string[]>();
|
var allowedOrigins = builder.Configuration.GetSection("Cors:AllowedOrigins").Get<string[]>();
|
||||||
|
|
||||||
builder.Services.AddCors(options =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
options.AddPolicy(name: MyAllowSpecificOrigins,
|
options.AddPolicy(name: MyAllowSpecificOrigins,
|
||||||
policy =>
|
policy =>
|
||||||
{
|
{
|
||||||
policy.WithOrigins("http://127.0.0.1:5500",
|
policy.WithOrigins(allowedOrigins)
|
||||||
"http://localhost:5500")
|
|
||||||
.AllowAnyMethod()
|
.AllowAnyMethod()
|
||||||
.AllowAnyHeader()
|
.AllowAnyHeader()
|
||||||
.AllowCredentials();
|
.AllowCredentials();
|
||||||
|
|||||||
@@ -4,5 +4,11 @@
|
|||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Cors": {
|
||||||
|
"AllowedOrigins": [
|
||||||
|
"http://127.0.0.1:5500",
|
||||||
|
"http://localhost:5500"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user