mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-30 09:59:41 +05:00
refactor: make related page view as list
This commit is contained in:
parent
4fb996353d
commit
99ea775e76
4 changed files with 201 additions and 57 deletions
|
@ -8,10 +8,14 @@ export const config = {
|
|||
|
||||
export default async function middleware(request: Request, context: NextFetchEvent) {
|
||||
if (request.method == "GET") {
|
||||
const url = request.url
|
||||
const path = url.match(/\/api\/proxy\/(.*)/)?.[1]
|
||||
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 data = await fetchDataViaGet(`${API_URL}/${path}`);
|
||||
const data = await fetchDataViaGet(`${API_URL}/${path}`, isApiV2);
|
||||
|
||||
if (!data) {
|
||||
return new Response(JSON.stringify({ message: "Error Fetching Data" }), {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue