From d8c9ea460c5945d15f738ce4cb670d9b75a8d9b6 Mon Sep 17 00:00:00 2001 From: AndreStork Date: Thu, 20 Nov 2025 09:38:16 +0100 Subject: [PATCH] Fix origini CORS su file di configurazione --- PizzaExpress/Program.cs | 5 ++--- PizzaExpress/appsettings.Development.json | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/PizzaExpress/Program.cs b/PizzaExpress/Program.cs index bac0cee..50ce49a 100644 --- a/PizzaExpress/Program.cs +++ b/PizzaExpress/Program.cs @@ -10,15 +10,14 @@ namespace PizzaExpress var MyAllowSpecificOrigins = "_myAllowSpecificOrigins"; var builder = WebApplication.CreateBuilder(args); - var allowedOrigins = builder.Configuration.GetSection("AllowedOrigins").Get(); + var allowedOrigins = builder.Configuration.GetSection("Cors:AllowedOrigins").Get(); builder.Services.AddCors(options => { options.AddPolicy(name: MyAllowSpecificOrigins, policy => { - policy.WithOrigins("http://127.0.0.1:5500", - "http://localhost:5500") + policy.WithOrigins(allowedOrigins) .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials(); diff --git a/PizzaExpress/appsettings.Development.json b/PizzaExpress/appsettings.Development.json index ff66ba6..68c8e17 100644 --- a/PizzaExpress/appsettings.Development.json +++ b/PizzaExpress/appsettings.Development.json @@ -4,5 +4,11 @@ "Default": "Information", "Microsoft.AspNetCore": "Warning" } + }, + "Cors": { + "AllowedOrigins": [ + "http://127.0.0.1:5500", + "http://localhost:5500" + ] } }