diff --git a/app/providers/ConsolidatedProviders.tsx b/app/providers/ConsolidatedProviders.tsx index 57c8ffbc..ea8a7d55 100644 --- a/app/providers/ConsolidatedProviders.tsx +++ b/app/providers/ConsolidatedProviders.tsx @@ -103,10 +103,25 @@ export function NavigationProviders({ children }: { children: React.ReactNode }) */ export function AllAppProviders({ children }: { children: React.ReactNode }) { const pathname = usePathname(); - const isRootOrAuthFlow = !pathname || pathname === '/' || pathname.startsWith('/auth'); - const isWelcomeFlow = pathname?.startsWith('/welcome'); - if (isRootOrAuthFlow) { + // During transitional renders where pathname is temporarily unavailable, + // use the full provider stack to avoid missing required contexts. + if (!pathname) { + return ( + + + + {children} + + + + ); + } + + const isAuthFlow = pathname.startsWith('/auth'); + const isWelcomeFlow = pathname.startsWith('/welcome'); + + if (isAuthFlow) { return ( {children} diff --git a/next.config.js b/next.config.js index fe6683c6..553b6da6 100644 --- a/next.config.js +++ b/next.config.js @@ -152,11 +152,15 @@ const nextConfig = { 'jose', ], - // Explicitly include jose in serverless function traces - // This fixes the "Cannot find package 'jose'" error on Vercel when using bun lockfile - // bun creates a .bun folder symlink structure that Vercel's runtime can't resolve + // Explicitly include jose + jwks-rsa in serverless function traces. + // IMPORTANT: Bun installs `node_modules/` as symlinks into `node_modules/.bun/...`. + // Including symlinked paths can produce invalid Vercel Serverless deployment packages. + // We therefore trace the real Bun store paths directly and avoid symlink globs. outputFileTracingIncludes: { - '/api/**/*': ['./node_modules/jose/**/*', './node_modules/jwks-rsa/**/*'], + '/api/**/*': [ + './node_modules/.bun/jose@*/node_modules/jose/**/*', + './node_modules/.bun/jwks-rsa@*/node_modules/jwks-rsa/**/*', + ], }, // Logging configuration @@ -239,7 +243,7 @@ const nextConfig = { "style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://connect-js.stripe.com https://*.stripe.com", "font-src 'self' https://fonts.gstatic.com", "img-src 'self' data: https: https://*.stripe.com https://*.tile.openstreetmap.org https://*.basemaps.cartocdn.com https://cdnjs.cloudflare.com", - "connect-src 'self' https://api.stripe.com https://connect-js.stripe.com https://*.stripe.com wss://*.stripe.com https://*.googleapis.com https://apis.google.com https://firebase.googleapis.com https://firestore.googleapis.com https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel https://firebaseinstallations.googleapis.com https://securetoken.googleapis.com https://identitytoolkit.googleapis.com wss://*.firebaseio.com https://*.firebaseio.com https://www.googletagmanager.com https://www.google-analytics.com https://analytics.google.com https://*.logrocket.io https://*.lr-ingest.io https://*.logrocket.com https://*.lr-in.com https://*.lr-in-prod.com https://*.lr-ingest.com https://*.ingest-lr.com https://cdn.lgrckt-in.com https://*.lgrckt-in.com https://va.vercel-scripts.com https://*.vercel-scripts.com wss://api.wewrite.app https://api.wewrite.app https://cdn.lordicon.com https://challenges.cloudflare.com", + "connect-src 'self' https://api.stripe.com https://connect-js.stripe.com https://*.stripe.com wss://*.stripe.com https://*.googleapis.com https://apis.google.com https://firebase.googleapis.com https://firestore.googleapis.com https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel https://firebaseinstallations.googleapis.com https://securetoken.googleapis.com https://identitytoolkit.googleapis.com wss://*.firebaseio.com https://*.firebaseio.com https://www.googletagmanager.com https://www.google-analytics.com https://analytics.google.com https://*.logrocket.io https://*.lr-ingest.io https://*.logrocket.com https://*.lr-in.com https://*.lr-in-prod.com https://*.lr-ingest.com https://*.ingest-lr.com https://cdn.lgrckt-in.com https://*.lgrckt-in.com https://*.logr-in.com https://va.vercel-scripts.com https://*.vercel-scripts.com wss://api.wewrite.app https://api.wewrite.app https://cdn.lordicon.com https://challenges.cloudflare.com", "report-uri /api/csp-violations", "frame-src 'self' https://js.stripe.com https://connect-js.stripe.com https://*.stripe.com https://*.firebaseapp.com https://wewrite-ccd82.firebaseapp.com https://challenges.cloudflare.com", "worker-src 'self' blob:",