Explorar el Código

fix: await dynamic params in GET /files/[id] route

vtugulan hace 6 meses
padre
commit
3f7a596c93
Se han modificado 1 ficheros con 3 adiciones y 2 borrados
  1. 3 2
      app/api/files/[id]/route.ts

+ 3 - 2
app/api/files/[id]/route.ts

@@ -5,11 +5,12 @@ const prisma = new PrismaClient();
 
 export const GET = async (
   req: NextRequest,
-  { params }: { params: { id: string } }
+  { params }: { params: Promise<{ id: string }> }
 ) => {
+  const { id } = await params;
   try {
     const file = await prisma.file.findUnique({
-      where: { id: params.id },
+      where: { id },
     });
 
     if (!file) {