From 7e48e097c0679e4c44cdd38ebe077ba94906a7ca Mon Sep 17 00:00:00 2001 From: Carl Tibule Date: Tue, 7 Feb 2023 22:13:26 -0600 Subject: [PATCH] Add CORS exception --- YABA.API/Program.cs | 8 ++++++++ YABA.API/appsettings.json | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/YABA.API/Program.cs b/YABA.API/Program.cs index bb8e69c..b9ae8be 100644 --- a/YABA.API/Program.cs +++ b/YABA.API/Program.cs @@ -103,4 +103,12 @@ app.MapControllers(); // Add custom middlewares app.UseMiddleware(); +app.UseCors(x => x + .AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader()); + +var webClientUrl = configuration.GetSection("WebClient").GetValue("Url"); +app.UseCors(x => x.AllowAnyHeader().AllowAnyMethod().WithOrigins(webClientUrl)); + app.Run(); diff --git a/YABA.API/appsettings.json b/YABA.API/appsettings.json index d9d9a9b..117c848 100644 --- a/YABA.API/appsettings.json +++ b/YABA.API/appsettings.json @@ -6,5 +6,7 @@ "Microsoft.Hosting.Lifetime": "Information" } }, - "AllowedHosts": "*" + "WebClient": { + "Url": "https://localhost:3000" + } }