Clever Tagline
Clever Tagline3mo ago

Error deploying to Vercel

I built my app using the Remix quickstart code from the docs, added Clerk for auth, and everything works fine locally. When deploying to Vercel per the Convex docs, however, it just generates a ton of errors. First on the list—and likely what's causing the rest—is ConvexReactClient requires a URL like 'https://happy-otter-123.convex.cloud'. I found other posts about this and manually added VITE_CONVEX_URL to the environment variables in the Vercel project settings (not mentioned in the docs, BTW), but it's still failing. Attached are screenshots of my Vercel config.
No description
No description
5 Replies
Convex Bot
Convex Bot3mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Clever Tagline
Clever TaglineOP3mo ago
Fixed a couple of minor issues that I found in the build logs, but that still hasn't fixed the error. Also updated the build command to this. Still not working.
npx convex deploy --cmd-url-env-var-name VITE_CONVEX_URL --cmd 'npm run build'
npx convex deploy --cmd-url-env-var-name VITE_CONVEX_URL --cmd 'npm run build'
If there's something wrong with the Clerk config, could that cause a problem like this? I won't have time to look into it until tonight at the soonest. I'm just trying to think of other things to check in the project setup. Like I said, everything (Clerk included) works fine when running locally. It just fails after deployment on Vercel.
erquhart
erquhart3mo ago
Has the error remained the same throughout Have you tried console logging the variable containing the url that you're passing to the react client
sshader
sshader3mo ago
Hmm you shouldn't have to be manually setting VITE_CONVEX_URL provided that you have a CONVEX_DEPLOY_KEY set and the build command updated. You said you're using Remix following the quickstart, which does new ConvexReactClient(ENV.CONVEX_URL) so I'd expect you'd want to set CONVEX_URL instead of VITE_CONVEX_URL unless you're doing something different here? Would love to see more of the logs from the failed build. I'd also double check that all of these failed builds are production builds (vs. preview builds that I believe vercel will automatically trigger on every PR to your repo). Also the error message here is not very helpful -- it usually happens when the value you're passing as the URL is undefined (it's already updated here but I don't think we've cut a release with it yet)
GitHub
convex-js/src/react/client.ts at 4353fa5ae40ce96df50f623d2095fbd91a...
TypeScript/JavaScript client library for Convex. Contribute to get-convex/convex-js development by creating an account on GitHub.
Clever Tagline
Clever TaglineOP3mo ago
Thanks for the tips. I totally forgot that the quickstart uses CONVEX_URL , so that could very likely be the culprit. I'll get back to this after work and let you know how it goes after checking that and the production vs preview setting on Vercel. If none of that works, I'll share a screenshot of the logs (the errors are all after deployment; the build runs error-free) Yeah, it's always the same error. I haven't tried logging yet, but I might give that a shot if the suggestions from @sshader don't fix it. Changing the build command to use CONVEX_URL fixed it. ✅ I even tested without forcing the env var name, and it still worked. Not sure why the build process didn't pick up that environment variable on its own originally. It might've had something to do with one of those minor errors I found in the build logs. Anyway, all is well! Sorry for not looking more carefully at the details.