From d776fb7f3344d9cf22b91f9c3588dd92c9a5fc3f Mon Sep 17 00:00:00 2001 From: b3b00 Date: Fri, 3 May 2024 10:15:01 +0200 Subject: [PATCH] hopeless try --- dendrOnlineSPA/NoCors.cs | 17 +++++++++++++++++ dendrOnlineSPA/Program.cs | 2 ++ 2 files changed, 19 insertions(+) create mode 100644 dendrOnlineSPA/NoCors.cs diff --git a/dendrOnlineSPA/NoCors.cs b/dendrOnlineSPA/NoCors.cs new file mode 100644 index 0000000..035234a --- /dev/null +++ b/dendrOnlineSPA/NoCors.cs @@ -0,0 +1,17 @@ +namespace dendrOnlineSPA; + +public static class NoCors +{ + public static WebApplication UseNoCors(this WebApplication app) + { + app.Use(async (context, next) => + { + context.Response.Headers.Add("Access-Control-Allow-Methods", "*"); + context.Response.Headers.Add("Access-Control-Allow-Headers", "*"); + context.Response.Headers.Add("Access-Control-Allow-Origin", "*"); + await next.Invoke(); + }); + + return app; + } +} \ No newline at end of file diff --git a/dendrOnlineSPA/Program.cs b/dendrOnlineSPA/Program.cs index a2c3eea..762299e 100644 --- a/dendrOnlineSPA/Program.cs +++ b/dendrOnlineSPA/Program.cs @@ -56,6 +56,8 @@ options.ExcludePath = "/health"; }); +app.UseNoCors(); + if (app.Environment.IsDevelopment()) { app.Run();