Remove env accesses at build time#77
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR delays Prisma and Supabase client initialization so imports do not read environment variables during build/deploy, while adding build-time public env wiring for the Docker/Fly deployment path.
Changes:
- Replaces eager Prisma/Supabase exports with lazy accessor functions.
- Updates API routes and registration service methods to call the lazy accessors.
- Adds Docker/Fly build args for public
NEXT_PUBLIC_*variables and expands.dockerignore.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/services/supabase.tsx |
Introduces lazy cached Supabase client creation. |
src/services/registrations/registrations-service.tsx |
Updates registration operations to call getSupabase() within methods. |
src/lib/prisma.ts |
Replaces eager Prisma singleton export with lazy getPrisma() accessor. |
src/app/api/claims/route.ts |
Updates public claims route to use lazy Prisma access. |
src/app/api/admin/revoke/route.ts |
Updates revoke route to use lazy Prisma access. |
src/app/api/admin/claims/route.ts |
Updates admin claims route to use lazy Prisma access. |
src/app/api/admin/approve/route.ts |
Updates approve route to use lazy Prisma access. |
src/app/admin/page.tsx |
Adds dynamic rendering configuration export. |
Dockerfile |
Adds public build args/env values needed by Next client bundling. |
.github/workflows/fly-deploy.yml |
Passes public build args to flyctl deploy. |
.dockerignore |
Expands ignored files and removes Dockerfile/README ignores. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+46
to
+50
| if (process.env.NODE_ENV !== "production") { | ||
| globalThis.prismaGlobal ??= createPrismaClient(); | ||
| return globalThis.prismaGlobal; | ||
| } | ||
| return createPrismaClient(); |
| return NextResponse.json({ error: "Address is required" }, { status: 400 }); | ||
| } | ||
|
|
||
| const prisma = getPrisma(); |
|
|
||
| export async function POST(req: NextRequest) { | ||
|
|
||
| const prisma = getPrisma(); |
Comment on lines
31
to
32
| const prisma = getPrisma(); | ||
| try { |
| const { searchParams } = new URL(req.url); | ||
| const status = searchParams.get("status"); | ||
|
|
||
| const prisma = getPrisma(); |
| if (!isAuth) | ||
| return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); | ||
|
|
||
| const prisma = getPrisma(); |
Comment on lines
32
to
34
| const prisma = getPrisma(); | ||
|
|
||
| try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
move prisma and supabase client call within methods to avoid deploy failure