Our application supports multiple domains. Is there a way to serve a different index.html file based on a domain in the request?
It doesn't look like firebase rewrites support that https://firebase.google.com/docs/hosting/full-config#rewrites
Business requirement: is to be able to serve different meta tags based on the domain
Current approach: have a separate hosting bucket for each domain that requires custom meta tags. This generally works but it has a problem of scale and we are simply duplicating resources as we need to upload the same files to every bucket.
Reviewed solution: to have 1 bucket and serve entry point (index.html) dynamically via firebase functions. Cons:
- Function needs to be redeployed every time we deploy new version
- Creates dependency between hosting and functions
We need to make sure that new index.html is served only after files are deployed. When you do
firebase deploy
it actually takes care of the order but wouldn’t be surprised if there are some edge cases - Makes it harder to do rollbacks as we would need to rollback file that function serves
Reviewed solution 2: Similar to reviewed solution above but instead of storing a file in functions folder we could download it via network request from the latest version of hosting folder