From 46ead16811ab230fc4f22d4a2c800d64e2d4f951 Mon Sep 17 00:00:00 2001 From: Radiquum Date: Sat, 30 Aug 2025 22:31:45 +0500 Subject: [PATCH 1/2] anix/fix: search in releases if no custom API is used --- middleware.ts | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/middleware.ts b/middleware.ts index 5408eba..903f9d7 100644 --- a/middleware.ts +++ b/middleware.ts @@ -10,19 +10,28 @@ export default async function middleware( request: Request, context: NextFetchEvent ) { - if (request.method == "GET") { - const url = new URL(request.url); - const isApiV2 = url.searchParams.get("API-Version") == "v2" || false; - if (isApiV2) { - url.searchParams.delete("API-Version"); - } - let path = url.pathname.match(/\/api\/proxy\/(.*)/)?.[1] + url.search; + const url = new URL(request.url); + let path = url.pathname.match(/\/api\/proxy\/(.*)/)?.[1] + url.search; + let isApiV2 = false; + if ( + url.searchParams.get("API-Version") && + url.searchParams.get("API-Version") == "v2" + ) { + isApiV2 = true; + url.searchParams.delete("API-Version"); + } else if ( + request.headers.get("api-version") && + request.headers.get("api-version") == "v2" + ) { + isApiV2 = true; + } + + if (request.method == "GET") { const { data, error } = await fetchDataViaGet( `${API_URL}/${path}`, isApiV2 ); - if (error) { return new Response(JSON.stringify(error), { status: 500, @@ -31,7 +40,6 @@ export default async function middleware( }, }); } - return new Response(JSON.stringify(data), { status: 200, headers: { @@ -41,13 +49,6 @@ export default async function middleware( } if (request.method == "POST") { - const url = new URL(request.url); - const isApiV2 = url.searchParams.get("API-Version") == "v2" || false; - if (isApiV2) { - url.searchParams.delete("API-Version"); - } - const path = url.pathname.match(/\/api\/proxy\/(.*)/)?.[1] + url.search; - const ReqContentTypeHeader = request.headers.get("Content-Type") || ""; const ReqSignHeader = request.headers.get("Sign") || null; let ResContentTypeHeader = ""; From 7cc36688e4f8e109423cfe00d7e5c09f53b549cf Mon Sep 17 00:00:00 2001 From: Kentai Radiquum <68120017+Radiquum@users.noreply.github.com> Date: Sat, 30 Aug 2025 22:36:40 +0500 Subject: [PATCH 2/2] Update 3.9.0.md --- public/changelog/3.9.0.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/changelog/3.9.0.md b/public/changelog/3.9.0.md index c782610..802414a 100644 --- a/public/changelog/3.9.0.md +++ b/public/changelog/3.9.0.md @@ -19,3 +19,6 @@ ## Удалено - Настройки показа названий страниц в навигации + +## 30-08-2025 +- Исправлен поиск по релизам если не используется свой сервер API