Home > OS >  Is it possible to redirect a custom URL of my domain to a Firebase Real-time DB path?
Is it possible to redirect a custom URL of my domain to a Firebase Real-time DB path?

Time:01-19

I need to expose a simple json value as a URL. The value is sometimes written by an automation (through CI/CD) and there are apps that query the endpoint for the value. Very simple.

I have figured that for our case exposing it through Firebase Real-time Database is simple enough to do so. The json value is already available through a link, however, I don't want to bake into all of our clients the exact Firebase URL. Later we might want to read this value from a different DB or use our backend, etc. So I thought maybe just a simple redirection would work:

  • Request to https://<my-domain>.com/<value-to-read>
  • Value is read from https://<project-id>.firebase.app.com/<path>/<value-to-read>.json
  • Value is returned

Now I have seen many tips for creating a mini-server/cloud function to query this value behind the scenes and then host this mini thing, put it on a custom domain and that's it.

But this is an overkill, because now for this very simple value getting now I would have to keep something version control, deploy it, monitor it, update it, etc.

I have not seen people simply redirecting the call from custom URL to concrete Firebase real-time database path.

TL;DR Summary and questions

  • I need to read a very simple json value, my choice is Firebase real-time DB.
  • For future proofing it, I wish to hide it's a Firebase RDB path the clients are accessing.
  • Considering my options I was thinking a redirect defined in our DNS service will be an optimal solution for this, but there might be a simpler possibility out there (I am open for suggestions).
  • Is it possible to just redirect and retrieve the value?
  • Am I correct with the assumption that this is set up completely outside of Firebase Console in the DNS service we use for our custom domains? Or are there any manual steps in Firebase Console as well?
  • Are there client-side edge-cases here I should know about, like "Oh, iOS apps really not do not handle well redirects"?

CodePudding user response:

There is no way to put a custom domain in front of Firebase Realtime Database.

If you want control over the domain, you'll need to set up your own server that then reads the data from Firebase (for example with Cloud Functions), or (if your data is mostly static) put the JSON files on a static file server or on a service like Firebase Hosting, where you can set up a custom domain name for it.

  • Related