Skip to content

Commit ac8f9b3

Browse files
committed
hotfix(registry): handle direct registry.json requests
Add special case handling for 'registry' and 'registry.json' requests to serve the full registry data. Include error handling when the registry file is not found.
1 parent 92e9f59 commit ac8f9b3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

app/registry/[componentName]/route.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,24 @@ import { NextResponse } from 'next/server';
55
export async function GET(
66
request: Request,
77
{ params }: { params: Promise<{ componentName: string }> }
8-
98
) {
109
let { componentName } = await params;
1110

11+
if (componentName === 'registry' || componentName === 'registry.json') {
12+
try {
13+
const registryFilePath = join(process.cwd(), 'registry.json');
14+
const registryFileContent = readFileSync(registryFilePath, 'utf-8');
15+
const registryData = JSON.parse(registryFileContent);
16+
17+
return NextResponse.json(registryData);
18+
} catch (error) {
19+
return new NextResponse(
20+
JSON.stringify({ error: `Registry file not found: ${error}` }),
21+
{ status: 404, headers: { 'content-type': 'application/json' } }
22+
);
23+
}
24+
}
25+
1226
// Supprimer l'extension .json si elle est présente
1327
if (componentName.endsWith('.json')) {
1428
componentName = componentName.slice(0, -5); // Enlève les 5 derniers caractères (.json)

0 commit comments

Comments
 (0)