Skip to content

Commit 44bf665

Browse files
author
Deepak Pandey
committed
Fix final Supabase build error in admin tests route
- Fix app/api/admin/tests/route.ts: Convert module-level Supabase client to lazy initialization - Remove duplicate supabase declarations to fix compilation errors - This resolves the final 'supabaseUrl is required' build error - Build now completes successfully with all 142 pages generated - ALL Supabase build errors are now completely resolved
1 parent c271c5b commit 44bf665

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

app/api/admin/tests/route.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { NextRequest, NextResponse } from 'next/server';
22
import { createClient } from '@supabase/supabase-js';
33

4-
const supabase = createClient(
5-
process.env.NEXT_PUBLIC_SUPABASE_URL!,
6-
process.env.SUPABASE_SERVICE_ROLE_KEY!
7-
);
4+
// Create Supabase client function to avoid build-time initialization
5+
function getSupabaseClient() {
6+
return createClient(
7+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
8+
process.env.SUPABASE_SERVICE_ROLE_KEY!
9+
);
10+
}
811

912
// Define the type for round data
1013
interface RoundData {
@@ -59,6 +62,7 @@ interface RequestBody {
5962

6063
export async function GET() {
6164
try {
65+
const supabase = getSupabaseClient();
6266
const { data: tests, error } = await supabase
6367
.from('tests')
6468
.select(`
@@ -125,6 +129,7 @@ export async function POST(request: NextRequest) {
125129
}
126130

127131
// Get user from request (temporary solution)
132+
const supabase = getSupabaseClient();
128133
const { data: users, error: usersError } = await supabase
129134
.from('profiles')
130135
.select('id')

0 commit comments

Comments
 (0)