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
You can set different environment variables in your convex deployments, you have one for development and one for production.
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
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?
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
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.
how would you go about qa, staging and prod environment?
I saw preview deployments
Yeah no long lived staging, preview deployments are the tool to use
But for right now, I'd recommend just having dev and prod.
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?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
Using Convex with Netlify | Convex Developer Hub
Host your frontend on Netlify and your backend on Convex.
convex deploy
accepts a follow up command, so it first deploys your backend, then runs your frontend build:
@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#callbacksredirectserver - Convex Auth
Authentication library for your Convex backend
thank you!