mirror of
https://github.com/Radiquum/AniX.git
synced 2025-09-08 15:33:53 +05:00
Compare commits
No commits in common. "7cc36688e4f8e109423cfe00d7e5c09f53b549cf" and "a4ecc27874a85fd33036f76eb004cb13f9f2eb18" have entirely different histories.
7cc36688e4
...
a4ecc27874
2 changed files with 16 additions and 20 deletions
|
@ -10,28 +10,19 @@ export default async function middleware(
|
||||||
request: Request,
|
request: Request,
|
||||||
context: NextFetchEvent
|
context: NextFetchEvent
|
||||||
) {
|
) {
|
||||||
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") {
|
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 { data, error } = await fetchDataViaGet(
|
const { data, error } = await fetchDataViaGet(
|
||||||
`${API_URL}/${path}`,
|
`${API_URL}/${path}`,
|
||||||
isApiV2
|
isApiV2
|
||||||
);
|
);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return new Response(JSON.stringify(error), {
|
return new Response(JSON.stringify(error), {
|
||||||
status: 500,
|
status: 500,
|
||||||
|
@ -40,6 +31,7 @@ export default async function middleware(
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response(JSON.stringify(data), {
|
return new Response(JSON.stringify(data), {
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -49,6 +41,13 @@ export default async function middleware(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.method == "POST") {
|
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 ReqContentTypeHeader = request.headers.get("Content-Type") || "";
|
||||||
const ReqSignHeader = request.headers.get("Sign") || null;
|
const ReqSignHeader = request.headers.get("Sign") || null;
|
||||||
let ResContentTypeHeader = "";
|
let ResContentTypeHeader = "";
|
||||||
|
|
|
@ -19,6 +19,3 @@
|
||||||
## Удалено
|
## Удалено
|
||||||
|
|
||||||
- Настройки показа названий страниц в навигации
|
- Настройки показа названий страниц в навигации
|
||||||
|
|
||||||
## 30-08-2025
|
|
||||||
- Исправлен поиск по релизам если не используется свой сервер API
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue