burnstony#1975
burnstony#19759mo ago

deploying mono repo with vercel

trying to deploy the monorepo using vercel imagine I will have to manually do the steps related to expo and the app deploy, but hoping to get vercel to deploy the web app
11 Replies
burnstony#1975
burnstony#1975OP9mo ago
first question what should the command be got this error ✖ In order to push, add convex to your package.json dependencies. Error: Command "npx convex deploy --cmd 'npm run build'" exited with 1 get this log Running 'npm run build' with environment variable "CONVEX_URL" set... instead of - Running 'npm run build' with environment variable "NEXT_PUBLIC_CONVEX_URL" set...
Michal Srb
Michal Srb9mo ago
You could try to cd into the project directory for the convex backend (the parent directory of your convex folder), in the build command, before running npx convex deploy.
burnstony#1975
burnstony#1975OP9mo ago
I’ll try that npx convex deploy --cmd 'npm run build; cd packages/backend’ The problem seems to be that its setting CONVEX_URL and not NEXT_PUBLIC_CONVEX_URL
Michal Srb
Michal Srb9mo ago
cd packages/backend && npx convex deploy --cmd 'npm run build' that's what I'd do. You can specify the env var name: cd packages/backend && npx convex deploy --cmd 'npm run build' --cmd-url-env-var-name NEXT_PUBLIC_CONVEX_URL see docs: https://docs.convex.dev/cli#deploy-convex-functions-to-production
CLI | Convex Developer Hub
The Convex command-line interface (CLI) is your interface for managing Convex
burnstony#1975
burnstony#1975OP9mo ago
Thank you now it says its deployed Deployed Convex functions to https://tame-condor-52.convex.cloud but I don't see any functions there on the convex dashboard
Michal Srb
Michal Srb9mo ago
Do you have the right deployment selected on the dashboard? The tame-condor-52 should show up in the URL. Also there's a History tab and Logs page, they would show the deployment.
burnstony#1975
burnstony#1975OP9mo ago
✔ Ran "npm run build" with environment variable "NEXT_PUBLIC_CONVEX_URL" set - Deploying to https://tame-condor-52.convex.cloud... ✔ Deployed Convex functions to https://tame-condor-52.convex.cloud' deployment history is only avialable on paid plans
burnstony#1975
burnstony#1975OP9mo ago
locally this /: npx convex deploy --cmd 'npm run build; cd packages/backend' --cmd-url-env-var-name NEXT_PUBLIC_CONVEX_URL erases all the functions in convex but /packages/backend:npm run build && cd packages/backend && npx convex deploy --cmd-url-env-var-name NEXT_PUBLIC_CONVEX_URL works got this to work, but my command basically has to build the code twice npx convex deploy --cmd 'npm run build' --cmd-url-env-var-name NEXT_PUBLIC_CONVEX_URL && cd packages/backend && npx convex deploy --cmd-url-env-var-name NEXT_PUBLIC_CONVEX_URL
Michal Srb
Michal Srb9mo ago
Aha, I see you need the URL to build the frontend and then to deploy from the right directory Your NEXT_PUBLIC_CONVEX_URL doesn't change, so you don't need to jump through these hoops. Simply: 1. Set NEXT_PUBLIC_CONVEX_URL on your hosting provider dashboard 2. Change the command to cd packages/backend && npx convex deploy && cd ../.. && npm run build NEXT_PUBLIC_CONVEX_URL is your Convex URL, you can see it on your Convex dashboard (for your prod deployment). This won't work for preview deployments though, there the URL does change. For preview deployment you can probably do something like: cd packages/backend && npx convex deploy --cmd 'echo NEXT_PUBLIC_CONVEX_URL=$CONVEX_URL > ../../.env' && cd ../.. && npm run build
burnstony#1975
burnstony#1975OP9mo ago
thanks - will try this if I can finish getting the eas expo build to run

Did you find this page helpful?