Skip to content

Commit d7d153a

Browse files
author
Deepak Pandey
committed
Fix final Supabase build error in generate-certificate route
- Fix app/api/admin/internships/generate-certificate/route.ts: Convert module-level Supabase client to lazy initialization - 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 9bff952 commit d7d153a

File tree

1 file changed

+8
-5
lines changed
  • app/api/admin/internships/generate-certificate

1 file changed

+8
-5
lines changed

app/api/admin/internships/generate-certificate/route.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import path from "path";
66
import { v4 as uuidv4 } from 'uuid';
77
import qrcode from 'qrcode';
88

9-
// Initialize Supabase client with service role
10-
const supabase = createClient(
11-
process.env.NEXT_PUBLIC_SUPABASE_URL!,
12-
process.env.SUPABASE_SERVICE_ROLE_KEY!
13-
);
9+
// Create Supabase client function to avoid build-time initialization
10+
function getSupabaseClient() {
11+
return createClient(
12+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
13+
process.env.SUPABASE_SERVICE_ROLE_KEY!
14+
);
15+
}
1416

1517
export async function POST(request: Request) {
1618
try {
@@ -20,6 +22,7 @@ export async function POST(request: Request) {
2022
}
2123

2224
// 1. Fetch profile to get the name
25+
const supabase = getSupabaseClient();
2326
const { data: profile, error: profileError } = await supabase
2427
.from("profiles")
2528
.select("first_name, last_name")

0 commit comments

Comments
 (0)