fix: desbloquear build na Vercel sem MONGODB_URI no compile time - #5
Draft
erikconnect wants to merge 1 commit into
Draft
fix: desbloquear build na Vercel sem MONGODB_URI no compile time#5erikconnect wants to merge 1 commit into
erikconnect wants to merge 1 commit into
Conversation
Defer MongoDB URI validation until connectDB() so Next.js can collect page data without crashing at module import time. Scrub committed Atlas credentials from docs/scripts, document MONGODB_URI in .env.example, and simplify vercel.json to rely on route-level maxDuration. Co-authored-by: Erik Assis Cardoso <erikconnect@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Problema
O deploy de produção mais recente falhou (
dpl_8Mu8VCGPdaSCAbYHZigKXEL2W37Q). Reproduzi localmente o mesmo erro dos logs típicos:src/lib/mongodb.tslançava no import do módulo. Durantenext build, o Next avalia rotas como/api/jobs/postings→store→mongodb, e o build quebra seMONGODB_URInão estiver presente no ambiente de build da Vercel.Além disso, credenciais do MongoDB Atlas estavam commitadas em docs/scripts.
Correção
MONGODB_URIsó emconnectDB()(runtime), não no top-levelnpm run buildpassa semMONGODB_URIUSER:PASSWORDMONGODB_URIdocumentado em.env.examplevercel.jsonsimplificado (cron mantido;maxDurationfica nos route handlers)Ainda necessário no dashboard da Vercel
MONGODB_URI,NEXTAUTH_SECRET,NEXT_PUBLIC_USE_STUBSworkforce-pulse.vercel.appaponta para este projeto Next.js — hoje o domínio público responde um HTML Vite estático (/assets/index-*.js), não o App Router0.0.0.0/0Testes
npm run build(sem env) ✅npm test✅