fix: nextjs unreliable params in route

This commit is contained in:
iCrawl
2023-12-21 05:19:32 +01:00
parent 1c3211a5fc
commit 520d6f64dd
2 changed files with 6 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
import { fetchVersions } from '~/app/docAPI';
export async function GET(_: NextRequest, params: { package: string }) {
return NextResponse.json(await fetchVersions(params.package));
export async function GET(req: NextRequest) {
const packageName = req.nextUrl.pathname.split('/').slice(2, 3)[0] ?? 'discord.js';
return NextResponse.json(await fetchVersions(packageName));
}