jordan
jordan3w ago

Any idea why `NEXT_PUBLIC_CONVEX_URL` is required in a vercel deployment of using convex auth?

this caused many hours of investigation and confusion. for some reason, upon deploying from vercel (preview & prod), NEXT_PUBLIC_CONVEX_URL was required ENV. there was an application server error due to it being missing. I assume triggered via convex-auth provider. During local development, this was never needed. My local .env did not include it. I did have NEXT_PUBLIC_CONVEX_CLOUD_URL which what was used when initializing the client auth via const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_CLOUD_URL!); however, no reference to NEXT_PUBLIC_CONVEX_URL within the project. we added the ENV and things started working in preview deployments, then forgot about it. turns out having that random ENV set incorrectly in our Prod environments caused auth to not work in production. However, everything failed silently. Convex logs indicated 200 success responses from the user creation, but no user was ever created. after remembering that random ENV that was required, we went and fixed the typo and everything works now. frustrating, and dont need help solving that issue anymore... but i am very confused and looking for insight, there's no mention of that being required in the auth provider docs.
8 Replies
Convex Bot
Convex Bot3w 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!
erquhart
erquhart3w ago
Hey, that's a rough experience. The env var you're referencing is generally used for convex w/ next - it's in the instructions for adding auth to next, for example: https://docs.convex.dev/client/react/nextjs/#adding-authentication
Next.js | Convex Developer Hub
How Convex works in a Next.js app
erquhart
erquhart3w ago
Is it not referenced in your codebase?
jordan
jordanOP3w ago
no it is not referenced in my codebase. i reference it as NEXT_PUBLIC_CONVEX_CLOUD_URL instead.
erquhart
erquhart3w ago
Convex logs indicated 200 success responses from the user creation, but no user was ever created.
Need to understand this part a bit better. Can you share any relevant config code to help troubleshoot? Are you passing any props to <ConvexAuthNextjsServerProvider>?
ian
ian3w ago
The auth provider defaults to that env variable name unless you override it, for a few things like the storageNamespace https://github.com/search?q=repo:get-convex/convex-auth%20NEXT_PUBLIC_CONVEX_URL&type=code
GitHub
Build software better, together
GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.
From An unknown user
From An unknown user
From An unknown user
erquhart
erquhart3w ago
Yeah but that should be throwing errors, they're saying it fails silently Here specifically https://github.com/get-convex/convex-auth/blob/10b4924e0b8e0a97d2130c01eaf02c8dd2b25fb6/src/nextjs/client.tsx#L59
ian
ian3w ago
In local dev maybe .env.local has the NEXT_PUBLIC_CONVEX_URL set, or maybe they're setting storageNamespace You can also call code that defaults to it in nextjs, such as fetchQuery or preloadQuery, if you don't pass in a custom url

Did you find this page helpful?