From 82dc5e3b5124e56bc9f297c5ebc79d0a84165c93 Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 20 Nov 2025 09:15:40 +0100 Subject: [PATCH] Spostamento origini CORS accettate in configurazione esterna --- PizzaExpress/PizzaExpress.csproj | 17 ++- PizzaExpress/Program.cs | 3 +- PizzaExpress/Properties/Resources.Designer.cs | 63 +++++++++++ PizzaExpress/Properties/Resources.resx | 101 ++++++++++++++++++ PizzaExpress/appsettings.json | 6 ++ 5 files changed, 188 insertions(+), 2 deletions(-) create mode 100644 PizzaExpress/Properties/Resources.Designer.cs create mode 100644 PizzaExpress/Properties/Resources.resx diff --git a/PizzaExpress/PizzaExpress.csproj b/PizzaExpress/PizzaExpress.csproj index c11f7f6..cab5d05 100644 --- a/PizzaExpress/PizzaExpress.csproj +++ b/PizzaExpress/PizzaExpress.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -14,4 +14,19 @@ + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + diff --git a/PizzaExpress/Program.cs b/PizzaExpress/Program.cs index b6626ff..bac0cee 100644 --- a/PizzaExpress/Program.cs +++ b/PizzaExpress/Program.cs @@ -10,7 +10,8 @@ namespace PizzaExpress var MyAllowSpecificOrigins = "_myAllowSpecificOrigins"; var builder = WebApplication.CreateBuilder(args); - + var allowedOrigins = builder.Configuration.GetSection("AllowedOrigins").Get(); + builder.Services.AddCors(options => { options.AddPolicy(name: MyAllowSpecificOrigins, diff --git a/PizzaExpress/Properties/Resources.Designer.cs b/PizzaExpress/Properties/Resources.Designer.cs new file mode 100644 index 0000000..86b002d --- /dev/null +++ b/PizzaExpress/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// Il codice è stato generato da uno strumento. +// Versione runtime:4.0.30319.42000 +// +// Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se +// il codice viene rigenerato. +// +//------------------------------------------------------------------------------ + +namespace PizzaExpress.Properties { + using System; + + + /// + /// Classe di risorse fortemente tipizzata per la ricerca di stringhe localizzate e così via. + /// + // Questa classe è stata generata automaticamente dalla classe StronglyTypedResourceBuilder. + // tramite uno strumento quale ResGen o Visual Studio. + // Per aggiungere o rimuovere un membro, modificare il file con estensione ResX ed eseguire nuovamente ResGen + // con l'opzione /str oppure ricompilare il progetto VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Restituisce l'istanza di ResourceManager nella cache utilizzata da questa classe. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PizzaExpress.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Esegue l'override della proprietà CurrentUICulture del thread corrente per tutte le + /// ricerche di risorse eseguite utilizzando questa classe di risorse fortemente tipizzata. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/PizzaExpress/Properties/Resources.resx b/PizzaExpress/Properties/Resources.resx new file mode 100644 index 0000000..4fdb1b6 --- /dev/null +++ b/PizzaExpress/Properties/Resources.resx @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PizzaExpress/appsettings.json b/PizzaExpress/appsettings.json index 4d56694..eb1e223 100644 --- a/PizzaExpress/appsettings.json +++ b/PizzaExpress/appsettings.json @@ -5,5 +5,11 @@ "Microsoft.AspNetCore": "Warning" } }, + "Cors": { + "AllowedOrigins": [ + "http://127.0.0.1:5500", + "http://localhost:5500" + ] + }, "AllowedHosts": "*" }