Sending data to EdgeDB on Fly.io from Website app. Is it possible?

I’m not exactly sure how this would work. I have a Remix react application running through Cloudflare pages. I can run server side code on there. For example, I have a form that on submit sends server side code having to do with Stripe payments.

Now I’m just wondering how would I go about connecting with my EdgeDB database from my website so that I can insert new data. Is it even possible?

The links below only mention connecting from a local machine or from another fly.io app. Do I have to have to compromise some security by turning some private networking off in the EdgeDB fly.io to make connecting to it easier?
EdgeDB on Fly · Fly Docs
Deploying EdgeDB to Fly.io — Deployment | EdgeDB Docs

Hi!

You could also connect to your EdgeDB via HTTPS but that would require you to slightly modify your fly.toml to add [[services]] that maps internal ports to external ports.

So let’s say you have this toml:

# more things here ^

[[services]]
http_checks   = []
internal_port = 1234
processes     = [ "app" ]
protocol      = "tcp"
script_checks = []

  [services.concurrency]
  hard_limit = 500
  soft_limit = 250
  type       = "requests"

  [[services.ports]]
  handlers = [ "http" ]
  port     = 80

  [[services.ports]]
  handlers = [ "tls", "http" ]
  port     = 443

  [[services.tcp_checks]]
  grace_period  = "1s"
  interval      = "15s"
  restart_limit = 6
  timeout       = "2s"

This means that your edgedb listens to port 1234 (change this internal_port to the correct value) and its mapped yo ports 80 and 443 which means you can connect via HTTP through https://your-app-name.fly.dev

Dont forget to deploy after changing your fly.toml

Please refer to EdgeDB docs to see how to connect: EdgeQL over HTTP — Client Libraries | EdgeDB Docs

The other route would be making your other hosting provider have Wireguard and setup a tunnel from Fly.io to there which is not that hard but takes time to setup.

1 Like

Thank you!!! I will try this out and get back to you.

Actually, before I get on moving on trying this out. Is there anyway to setup Wireguard with Cloudflare Pages?

I’d like to use the Typescript Queries I have setup within my Remix application if possible and not go to EdgeQL over HTTP

To my understanding CF Pages is for static only so my answer would be you could not use wireguard on it.

Alright. I switched the Remix app to Fly.io lol. Way easier of a hassle doing so than going through having to setup new EdgeQL query code.

Was actually easy this time. A month ago it never worked setting up a basic Remix site.

I’ll keep the toml for EdgeDB the same.

1 Like

Hey @goodunionjobs ,

i’m in the same situation, trying to run Remix + EdgeDB on fly.io

how did you end up connecting Remix and EdgeDB servers? Everything works locally for me (I have used the blues stack recipe), and I have successfully set up EdgeDB + postgres servers on Fly.io and I have them talking to each other, I just can’t complete the puzzle of connecting my Remix app to EdgeDB. I have the EDGEDB_DSN secret set, but not sure how to run the migration on deploy as it keeps complaining that edgedb is an unknown command (as expected), and even adding RUN curl https://sh.edgedb.com --proto '=https' -sSf1 | sh to my Remix app Docker image didn’t help.

Hey, I had to give up on EdgeDB and move to MySQL :confused: . It was just too much hassle and I needed to set everything up to be running soon. I’d recommend making your own post to try and get help on this issue.