Skip to content

Fix deployment build failures: lazy initialization and static generation#7

Draft
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-deployment-issues-again
Draft

Fix deployment build failures: lazy initialization and static generation#7
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-deployment-issues-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 26, 2025

Next.js build was failing due to API clients requiring credentials at module load time and pages attempting static generation without environment variables.

Changes

API Client Initialization

  • Implemented lazy initialization for Resend and Stripe clients to defer credential validation until runtime
  • Updated lib/stripe.ts, lib/email.tsx, and API routes to instantiate clients on-demand
// Before: fails at build time without STRIPE_SECRET_KEY
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!)

// After: defers initialization until route execution
function getStripe(): Stripe {
  if (!stripeInstance) {
    const secretKey = process.env.STRIPE_SECRET_KEY
    if (!secretKey) throw new Error("STRIPE_SECRET_KEY not set")
    stripeInstance = new Stripe(secretKey, { apiVersion: "2024-11-20.acacia" })
  }
  return stripeInstance
}

Google Fonts Loading

  • Switched from next/font/google (build-time fetching) to runtime loading via link tags
  • Added CSS custom properties in globals.css for font family fallbacks

Route Conflicts

  • Removed app/auth/callback/page.tsx conflicting with route.ts in same segment

Static Generation

  • Added export const dynamic = 'force-dynamic' to pages requiring database access (/browse-memorials, /products)
  • Changed invalid OpenGraph type: "product" to type: "website" for Next.js 14 compatibility

CI Workflow

  • Updated .github/workflows/webpack.yml to use npm run build instead of npx webpack

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/v0-memorialqrwebsitecode/v0-memorialqrwebsitecode/node_modules/next/dist/compiled/jest-worker/processChild.js (dns block)
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/v0-memorialqrwebsitecode/v0-memorialqrwebsitecode/node_modules/next/dist/compiled/jest-worker/processChild.js -m owner --uid-owner 0 -j ACCEPT (dns block)
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/v0-memorialqrwebsitecode/v0-memorialqrwebsitecode/node_modules/next/dist/compiled/jest-worker/processChild.js REDACTED build git conf�� submodules | head -n 10 --local rgo/bin/node credential.helpe/usr/local/bin/node (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Fix deployment issues


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
v0-deal-patrol-v0-memorialqrwebsite Ready Ready Preview, Comment Dec 26, 2025 6:52pm
v0-e-commerce-online-shopping-app Ready Ready Preview, Comment Dec 26, 2025 6:52pm
v0-memorialqrwebsitecode-90 Ready Ready Preview, Comment Dec 26, 2025 6:52pm
v0-memorialqrwebsitecode-rmd2 Ready Ready Preview, Comment Dec 26, 2025 6:52pm
v0-nano-banana-pro-playground Ready Ready Preview, Comment Dec 26, 2025 6:52pm

Co-authored-by: DealPatrol <118781133+DealPatrol@users.noreply.github.com>
… font loading, update CI workflow

Co-authored-by: DealPatrol <118781133+DealPatrol@users.noreply.github.com>
Copilot AI and others added 2 commits December 26, 2025 18:35
Co-authored-by: DealPatrol <118781133+DealPatrol@users.noreply.github.com>
Co-authored-by: DealPatrol <118781133+DealPatrol@users.noreply.github.com>
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.

2 participants