diff --git a/app/api/users/[userId]/roles/route.ts b/app/api/users/[userId]/roles/route.ts index c55a6f6d..aec8867c 100644 --- a/app/api/users/[userId]/roles/route.ts +++ b/app/api/users/[userId]/roles/route.ts @@ -5,7 +5,7 @@ import { getKeycloakAdminClient } from "@/lib/keycloak"; export async function GET( request: Request, - context: { params: { userId: string } } + { params }: { params: { userId?: string } } ) { try { const session = await getServerSession(authOptions); @@ -13,8 +13,9 @@ export async function GET( return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); } - // Use the userId from context instead of trying to destructure it - const userId = context.params.userId.toString(); + // Just get the primitive value directly + const rawUserId = params?.userId; + const userId = typeof rawUserId === 'string' ? rawUserId : ''; if (!userId) { return NextResponse.json({ error: "User ID is required" }, { status: 400 }); @@ -75,7 +76,7 @@ export async function GET( export async function PUT( request: Request, - context: { params: { userId: string } } + { params }: { params: { userId?: string } } ) { try { const session = await getServerSession(authOptions); @@ -83,8 +84,9 @@ export async function PUT( return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); } - // Use the userId from context instead of trying to destructure it - const userId = context.params.userId.toString(); + // Just get the primitive value directly + const rawUserId = params?.userId; + const userId = typeof rawUserId === 'string' ? rawUserId : ''; if (!userId) { return NextResponse.json({ error: "User ID is required" }, { status: 400 });