Search code examples
firebasereverse-proxyfirebase-hosting

Serving Google Firebase hosted project from sub-folder of another site


We've built a Vue app for a client that utilises Google Firebase Auth, the Firestore and some Cloud Functions. It's currently being served on a subdomain of their main site, in the structure app.example.com. Their main site is not in our control and is not hosted by Google nor does it utilise Firebase in any way. They've asked whether it would be possible to serve our app from a sub-directory of their main site instead, for example, www.example.com/app/.

From reading around, I understand this is normally technically possible by using something called a reverse-proxy (I think!) but I wanted to check, given our setup with Firebase, could this be done? My concerns are:

  • SSL certs are auto-provisioned by Firebase and cover the subdomain only (I assume). If the TLD had a wildcard SSL in place, would it be okay?
  • All of the files, auth, firestore and functions are contained within the same Google Firebase project and I'm worried because the TLD isn't an "authorised domain" it won't work.
  • It's beyond me but I read a few posts referencing load balancers on Google's side - would these still work if a reverse-proxy was utilised?

We've got a team of devs who will be able to get there if it's possible, I just don't want to send them on a wild goose chase now if it's definitely not doable. Any thoughts would be very welcome.


Solution

  • Firebase Hosting needs to be configured as the sole domain from which it serves content. It can't be served from (only) a subfolder on a domain, as the traffic wouldn't reach Firebase until you configure it as the destination for the entire domain.

    A reverse proxy would work indeed, but that just means that you move the serving of the content elsewhere. You'd set up a reverse proxy for www.example.com/app/ on a hosting provider that does support that (so not Firebase Hosting) and the reverse proxy then reads the content from app.example.com, which can be on Firebase Hosting.

    Similarly, you could set up Firebase Hosting as the DNS destination, and then have a reverse proxy in the root there that reads the contents from your original www.example.com server as needed and serves it to the visitors.