kstulgys
kstulgys5mo ago

I want to deploy my website that uses convex development environment, how do I deal with SITE_URL?

I use convex auth, there are some variables that is required like SITE_URL. For this I use http://localhost:3000 when running locally, but I want to deploy my site as i.e xyz-test.com how can I manage different SITE_URL in this case?
13 Replies
erquhart
erquhart5mo ago
You can set different environment variables in your convex deployments, you have one for development and one for production.
kstulgys
kstulgysOP5mo ago
I know I already have SITE_URL: http://localhost:3000/ in my development environment but when I deploy my frontend it will be https://xyz-test.com how do I point to that? I do not want to do a production deployment I want to use same convex environment (development) for both: local and deployed
erquhart
erquhart5mo ago
I'm honestly not sure how you'd go about that, it would be working around the system. Can I ask why you don't want to use the production deployment?
kstulgys
kstulgysOP5mo ago
because it's not prod ready, I will likely be messing around with schema a lot, but I want my app to be publicly accessible
erquhart
erquhart5mo ago
Honestly production is great for that. There aren't downsides to using it before you're "production ready". My main project was in "production" for years before having real users.
kstulgys
kstulgysOP5mo ago
how would you go about qa, staging and prod environment? I saw preview deployments
erquhart
erquhart5mo ago
Yeah no long lived staging, preview deployments are the tool to use But for right now, I'd recommend just having dev and prod.
kstulgys
kstulgysOP5mo ago
is there a github action example that runs npx convex deploy when changes are detected in schema.ts? otherwise I would need to run this myself from conole right?
erquhart
erquhart5mo ago
Yep, I have a make script that runs linters, deploys to prod, releases, etc I haven't seen an action example yet It'd be very straightforward though A typical pattern is to have your deployment provider, eg., Netlify, run the convex deploy command Since Netlify is already hooked into your Git workflow and only deploys when things are merged to main, any CI you set up will have already passed
erquhart
erquhart5mo ago
convex deploy accepts a follow up command, so it first deploys your backend, then runs your frontend build:
npx convex deploy --cmd 'npm run build'
npx convex deploy --cmd 'npm run build'
Michal Srb
Michal Srb5mo ago
@kstulgys if you need multiple SITE_URLs you need to provide the URL in redirectTo param to signIn and validate them in redirect callback: https://labs.convex.dev/auth/api_reference/server#callbacksredirect
server - Convex Auth
Authentication library for your Convex backend
kstulgys
kstulgysOP5mo ago
thank you!

Did you find this page helpful?