diff --git a/src/app/api/forum/user-by-username/[username]/route.ts b/src/app/api/forum/user-by-username/[username]/route.ts index a70950a..61ac981 100644 --- a/src/app/api/forum/user-by-username/[username]/route.ts +++ b/src/app/api/forum/user-by-username/[username]/route.ts @@ -25,6 +25,9 @@ export async function GET( // 1) Profile — accept EITHER username OR display_name (URL-encoded). // forum_threads/forum_replies store author_name = display_name, // so the link in the UI uses the display name; we resolve it here. + // Multiple profiles can share a display_name (Michael Carter, Alex Rivera, + // etc.) — pick the earliest-created profile deterministically rather than + // erroring out with maybeSingle(). const decoded = decodeURIComponent(username); let { data: profile } = await sb .from("forum_user_profiles") @@ -36,8 +39,9 @@ export async function GET( .from("forum_user_profiles") .select("*") .eq("display_name", decoded) - .maybeSingle(); - profile = r2.data; + .order("created_at", { ascending: true }) + .limit(1); + profile = (r2.data && r2.data[0]) || null; } if (!profile) {