Skip to content
Merged

debug #226

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/[nsfront]/[nsbehind]/[name]/[version]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const CratePage = () => {
const [depCurrentPage, setDepCurrentPage] = useState(1);
const [versions, setVersions] = useState<string[]>([]);
const itemsPerPage = 1;
const basePath = `/${params.nsfront}/${params.nsbehind}/${params.name}`;
const basePath = `/${params.nsfront}/${params.nsbehind}/${params.name}/${params.version}`;

useEffect(() => {
const fetchCrateData = async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { NextRequest, NextResponse } from "next/server";
type Params = Promise<{ nsfront: string, nsbehind: string, cratename: string, version: string }>
export async function GET(req: NextRequest, props: { params: Params }) {
try {
const params = await props.params
const { nsfront, nsbehind, cratename, version } = params;
const endpoint = process.env.CRATES_PRO_INTERNAL_HOST;

const externalApiUrl = `${endpoint}/api/crates/${nsfront}/${nsbehind}/${cratename}/${version}/unsafechecker`;
const externalRes = await fetch(externalApiUrl);
if (!externalRes.ok) {
throw new Error('Failed to fetch external data');
}
const externalData = await externalRes.json();
console.log('External API Response:', externalData);
return NextResponse.json(externalData);
} catch (error) {
console.error('Error:', error);
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });

}
}