@@ -125,16 +125,8 @@ export async function POST(
125125 }
126126 }
127127
128- // 3. User Lookup (Bypass RLS using Admin Client)
129- // We need to find the user by email, but normal users might not have permission to list/search profiles
130- const { createAdminClient } = await import ( "@/lib/database/supabase-admin" )
131- const supabaseAdmin = createAdminClient ( )
132-
133- if ( ! supabaseAdmin ) {
134- return NextResponse . json ( { error : "Server configuration error" } , { status : 500 } )
135- }
136-
137- const { data : userProfile , error : profileError } = await supabaseAdmin
128+ // 3. User Lookup
129+ const { data : userProfile , error : profileError } = await supabase
138130 . from ( "profiles" )
139131 . select ( "*" )
140132 . ilike ( "email" , email . trim ( ) )
@@ -155,9 +147,9 @@ export async function POST(
155147 )
156148 }
157149
158- // 4. Add Collaborator (Use Admin Client to ensure insert succeeds regardless of RLS)
150+ // 4. Add Collaborator
159151 // First check if already exists
160- const { data : existingCollab } = await supabaseAdmin
152+ const { data : existingCollab } = await supabase
161153 . from ( "project_collaborators" )
162154 . select ( "user_id" )
163155 . eq ( "project_id" , projectId )
@@ -171,7 +163,7 @@ export async function POST(
171163 )
172164 }
173165
174- const { data : newCollaborator , error : insertError } = await supabaseAdmin
166+ const { data : newCollaborator , error : insertError } = await supabase
175167 . from ( "project_collaborators" )
176168 . insert ( {
177169 project_id : projectId ,
0 commit comments