Using Convex with Vercel | Convex Develo...
i tried following this, deploying to vercel https://docs.convex.dev/production/hosting/vercel
i had a deployment already, but changed build + env vars
now i get a server errors strangely
Using Convex with Vercel | Convex Developer Hub
Host your frontend on Vercel and your backend on Convex.
29 Replies
seems like ENV is undefined
maybe prod env vars missing
what errors are you getting?
ENV is undefined
Error: ConvexReactClient requires a URL like 'https://happy-otter-123.convex.cloud'.
but its weird, i added it to the env vars
followed the docs
but it wasn't a new deployment tho
an existing one where i configured the env vars and override the build command
npx convex deploy --cmd-url-env-var-name CUSTOM_CONVEX_URL --cmd 'npm run build'
i tried this too
which did go through successfully
redeplyoing and looking at the logs
goshhh
i just wanna set it up so i can code man 😭
deleted my project
new vercel project
deploying again
congrats confetti with unexpected server error cmon

@MapleLeaf 🍁 do you've any idea of issues u ran into urself when deploying to vercel?
i followed this but no luck https://docs.convex.dev/production/hosting/vercel
Using Convex with Vercel | Convex Developer Hub
Host your frontend on Vercel and your backend on Convex.
that looks like more of a remix issue than a vercel issue
in fact can you show your code that the error is pointing at? the
useLoaderData()
callbut env should be there, i did set the env var
i followed the remix docs for convex
im wondering of convex auth needs its own "auth" thing deployed too
whys it accessed via brackets like that?
well, either way, if you're using remix vite, you don't need to use a loader to pass the variable
import meta should work?
ahh
yeah
has to start with
VITE_
but yeahCONVEX_DEPLOYMENT too
gotta start with vite?
that one i don't think needs to be set in vercel at all
that's just for the CLI afaik
but in vercel
its gotta be "vite" too
yeah
bc i have CONVEX_DEPLOY_KEY there
thats the one im talking about
oh, not that one
its confusing bc afaik that one should infer the convex url for me
but the vite convex url i gotta set myself
itseems like
that should get set by the build step
if the default one isn't right, you need to pass
--env-var-name
or something like thatgotcha

lets see if its setting the right one now
:Spooked:
no........
:AnimeTiredS:
Error: ConvexReactClient requires a URL like 'https://happy-otter-123.convex.cloud'.
the command "npx convex deploy --cmd-url-env-var-name https://terrific-toucan-239.convex.cloud --cmd 'npm run build'"
but how can i tell it
it should be VITE_CONVEX_URL
...
did it manually
ok it works now
npx conved deploy
u gonna make me rip my hair out
:spookySPOOKY:
also im much more comfortable with this approach
let me set the env vars im suppose. to set
and then let it all just "work" as a backend
no need to set the env var for me
yeah
i should've just followed my instincts from the get go
lol nice
im using the same JWKS and JWT_PRIVATE_KEY as dev
i dont think it should be an issue
its just for convenience
@Wayne @Michal Srb let me know if its an issue using the same auth env vars as dev
specifically JWT_PRIVATE_KEY and JWKS
i know google id and secret should be diff
as for SITE_URL it should be the deployed URL on vercel (just asking as confirmation)
ok
seems like my instincts were ok
yeah
it all works
now i got it deployed to prod which is nice
that's all setup
google oauth
apple oauth and then email/password
...i guess this entire experience is a feedback for you
TLDR:
- tell me what environment variables i should add to vercel
- let me deploy normally, no need to override build command and let u handle env vars, its super simple, no need for magic
as for convex prod project, u kind of documented it there already even tho i was confused
but yeah, that i need to add the environment variables over at the convex production project too
let me deploy normally, no need to override build commandThis is set up for preview deployments, where you don't know beforehand what the URL of your backend is. (Convex Auth doesn't support preview deployments yet though, as it will need to proxy for OAuth).
that i need to add the environment variables over at the convex production project toohttps://labs.convex.dev/auth/production Is there something missing from this page?
Production - Convex Auth
Authentication library for your Convex backend
i missed this one!