From 1260cdecc8dd3f7b2573d0e1ba362359c8f586c3 Mon Sep 17 00:00:00 2001 From: pagoru Date: Mon, 29 Jun 2026 00:08:00 +0200 Subject: [PATCH] fix: fixed cors for found requests + deleted response OK when metho not found - fix #127 --- src/modules/api.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/api.ts b/src/modules/api.ts index 757c208..a49792b 100644 --- a/src/modules/api.ts +++ b/src/modules/api.ts @@ -7,7 +7,7 @@ import { import { REQUEST_KIND_COLOR_MAP } from "../consts/request.consts.ts"; import { getResponse } from "../utils/response.utils.ts"; import { HttpStatusCode } from "../enums/http-status-code.enums.ts"; -import { appendCORSHeaders } from "../utils/cors.utils.ts"; +import { appendCORSHeaders, getCORSHeaders } from "../utils/cors.utils.ts"; export const getApiHandler = ({ requests, @@ -79,7 +79,13 @@ export const getApiHandler = ({ return response; } - if (foundRequests.length) return getResponse(HttpStatusCode.OK); + //CORS + if (foundRequests.length && method === RequestMethod.OPTIONS) { + return new Response(null, { + headers: getCORSHeaders(), + status: 204, + }); + } return getResponse(HttpStatusCode.NOT_FOUND); };