From 7e4f43f1e27e9d211505a4b6287708056898e8c1 Mon Sep 17 00:00:00 2001 From: glax Date: Wed, 21 Jun 2023 16:53:07 +0200 Subject: [PATCH] API fix CORS preflight --- API/Server.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/API/Server.cs b/API/Server.cs index ab69b5a..d23e0f0 100644 --- a/API/Server.cs +++ b/API/Server.cs @@ -54,8 +54,15 @@ public class Server SendResponse(HttpStatusCode.BadRequest, response); return; } - - _requestHandler.HandleRequest(request, response); + + if (request.HttpMethod == "OPTIONS") + { + SendResponse(HttpStatusCode.OK, response); + } + else + { + _requestHandler.HandleRequest(request, response); + } } internal void SendResponse(HttpStatusCode statusCode, HttpListenerResponse response, object? content = null)