Kiran
Kiran6mo ago

Self-hosting convex on domain with cloudflare

I'm running the convex open source backend, which works great locally. I wanted to expose it through a cloudflare tunnel on my custom domain name so I could access it from other devices, but when I expose port 3210 (which is what I saw being used in the just file) through a cloudflare tunnel to my domain at convex.---.com, and then replace the --url param with the new url, it doesn't work. I see the following error from the just convex dev command (replaced my domain with ---)
✖ Error: Unable to run schema validation on http://convex.---.com
Error fetching POST http://convex.---.com/api/prepare_schema 405 Method Not Allowed
✖ Error: Unable to run schema validation on http://convex.---.com
Error fetching POST http://convex.---.com/api/prepare_schema 405 Method Not Allowed
I'm guessing it's because it needs a proxy URL set so it knows where to send API requests. Is there a way to fix this?
14 Replies
nipunn
nipunn6mo ago
I've never done this setup before, so you're breaking some new ground here. Seems like it should work. Probably a good place to start is figuring out whether the request is getting to convex-backend or not. You can look at loglines from your convex-local-backend executable and see if it is receiving the prepare_schema If I had to guess, it's probably the cloudflare tunnel that is returning the 405 - so you may want to check configuration there first
Kiran
KiranOP6mo ago
Thanks, I just checked it. It looks like the convex-local-backend is actually receiving the requests, and returning a 405? Any idea what's causing this? Here's the log. It keeps repeating this since the client is also trying to retry connecting.
2024-07-24T17:22:23.709946Z INFO convex-cloud-http: [] 127.0.0.1:63406 "GET /api/prepare_schema HTTP/1.1" 405 "-" "undici" 46.8µs
2024-07-24T17:22:23.709946Z INFO convex-cloud-http: [] 127.0.0.1:63406 "GET /api/prepare_schema HTTP/1.1" 405 "-" "undici" 46.8µs
lee
lee6mo ago
if you contrast
Error fetching POST http://convex.---.com/api/prepare_schema
Error fetching POST http://convex.---.com/api/prepare_schema
with
"GET /api/prepare_schema HTTP/1.1"
"GET /api/prepare_schema HTTP/1.1"
you see that somehow the client's POST request is becoming a GET request by the time it gets to convex i don't know why the cloudflare tunnel would change the method of the HTTP request 😕
v
v6mo ago
It works perfectly for me with cloudflare tunnels I didn't use just thought, I'll look at the justfile Ah maybe it's because the use of http and not https @Kiran can you make sure your url scheme is https
Kiran
KiranOP6mo ago
that worked, thanks so much!
v
v6mo ago
Ofcourse
Kiran
KiranOP6mo ago
Do you know how self-hosted convex works when multiple devs connect to the same instance during development? Will the convex functions conflict and overwrite the other devs' code as they save, or does it use different device id's like the hosted convex version? (I know ideally devs should work on an isolated instance instead, but wanted to check how this works)
v
v6mo ago
I'm not sure, I haven't done an actual project with convex yet, especially with another dev. Butttt if I had to guess it would work Just a guess I really don't know I would just test it
Kiran
KiranOP6mo ago
thanks, I'll try it out with 2 slightly modified projects at the same time and see what happens on diff devices*
v
v6mo ago
Let me know the results I'm curious There's not much code related to teams on the rust side of things it seems atleast from what I seen @ari probably knows Hmmm
v
v6mo ago
Convex | The fullstack TypeScript development platform
The backend application platform with everything you need to build your product.
v
v6mo ago
Idk what this is but it seems related
lee
lee6mo ago
This flow isn't supported, since you're correct that the two npx convex dev commands will compete with each other. I recommend having only one npx convex dev running. You can still run two frontend servers (npm run dev:frontend) connected to the same convex instance
Kiran
KiranOP6mo ago
thanks, makes sense

Did you find this page helpful?