浏览代码

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

vtugulan 6 月之前
父节点
当前提交
3f7a596c93
共有 1 个文件被更改,包括 3 次插入2 次删除
  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) {