From 2d341ff494d60e1b58ae4d6d5c1d4052ddfcd4a5 Mon Sep 17 00:00:00 2001 From: ppc Date: Thu, 8 Aug 2024 23:45:41 +0100 Subject: [PATCH 1/2] enable cors --- AimeNet/DllMain.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/AimeNet/DllMain.cs b/AimeNet/DllMain.cs index ef4711d..6f621aa 100644 --- a/AimeNet/DllMain.cs +++ b/AimeNet/DllMain.cs @@ -57,6 +57,15 @@ public static class DllMain builder.Logging.AddFilter("Microsoft.AspNetCore.Routing.EndpointMiddleware", LogLevel.Error); builder.WebHost.UseUrls(_serverAddresses); + builder.Services.AddCors(cors => + { + cors.AddDefaultPolicy(policy => + { + policy.AllowAnyMethod(); + policy.AllowAnyOrigin(); + }); + }); + builder.Services.ConfigureHttpJsonOptions(options => { options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default); @@ -64,6 +73,8 @@ public static class DllMain var app = builder.Build(); + app.UseCors(); + app.MapGet("/", () => Results.Ok(new SystemState(ApiVersion, _serverName))); app.MapPost("/card", async ctx => { From 01acdfe3348c07cea9a56dee12e8bcaa3aa5b372 Mon Sep 17 00:00:00 2001 From: ppc Date: Thu, 8 Aug 2024 23:46:56 +0100 Subject: [PATCH 2/2] set preflight max age --- AimeNet/DllMain.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AimeNet/DllMain.cs b/AimeNet/DllMain.cs index 6f621aa..b785f61 100644 --- a/AimeNet/DllMain.cs +++ b/AimeNet/DllMain.cs @@ -63,6 +63,8 @@ public static class DllMain { policy.AllowAnyMethod(); policy.AllowAnyOrigin(); + + policy.SetPreflightMaxAge(TimeSpan.FromHours(6)); }); });