Skip to content

Remove env accesses at build time#77

Merged
rebeccafitzpatr merged 8 commits into
mainfrom
remove-env-accesses-at-build-time
May 27, 2026
Merged

Remove env accesses at build time#77
rebeccafitzpatr merged 8 commits into
mainfrom
remove-env-accesses-at-build-time

Conversation

@rebeccafitzpatr
Copy link
Copy Markdown
Collaborator

move prisma and supabase client call within methods to avoid deploy failure

Copilot AI review requested due to automatic review settings May 27, 2026 07:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread src/lib/prisma.ts Outdated
Comment on lines +46 to +50
if (process.env.NODE_ENV !== "production") {
globalThis.prismaGlobal ??= createPrismaClient();
return globalThis.prismaGlobal;
}
return createPrismaClient();
Copy link
Copy Markdown

@TheSKBroook TheSKBroook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copilot AI review requested due to automatic review settings May 27, 2026 21:32
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.

Comment thread src/app/api/claims/route.ts Outdated
return NextResponse.json({ error: "Address is required" }, { status: 400 });
}

const prisma = getPrisma();
Comment thread src/app/api/claims/route.ts Outdated

export async function POST(req: NextRequest) {

const prisma = getPrisma();
Comment thread src/app/api/admin/approve/route.ts Outdated
Comment on lines 31 to 32
const prisma = getPrisma();
try {
Comment thread src/app/api/admin/claims/route.ts Outdated
const { searchParams } = new URL(req.url);
const status = searchParams.get("status");

const prisma = getPrisma();
Comment thread src/app/api/admin/claims/route.ts Outdated
if (!isAuth)
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });

const prisma = getPrisma();
Comment thread src/app/api/admin/revoke/route.ts Outdated
Comment on lines 32 to 34
const prisma = getPrisma();

try {
@rebeccafitzpatr rebeccafitzpatr merged commit ce349d5 into main May 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants