Search code examples
firebasednsfirebase-hosting

How do I serve a firebase site using the domain from another firebase site?


I have a firebase site with a domain of gs-domain1.web.app. I have a second firebase site with a domain of gs-domain1.web.app.

Now, I want all traffic to go through the gs-domain1.web.app. However, when the path matches a specific route, like, /users/:id/pages, I want the site on gs-domain2.web.app to take over without switching the domain, but maintaining the path.

I believe a redirect will not work because it physically switches the domain. I believe a rewrite will not work because I can't recreate the path on the destination.

Both the application on domain1 and domain2 are single-page applications (react and vue respectfully).


Solution

  • In firebase, you could host more than one site in one project and that would solve your problem.

    Host/Deploy the react code to firebase and link the site with the URL of gs-domain2.web.app and do another hosting in the same project as the react but vue on gs-domain2.web.app

    After you have successfully linked the domain and hosted the sites... Link the URL together with or anyone you like.

    PROS: Your sites would load separately and would be faster.

    Also,

    It would be great if you put all the code under one domain

    Then you can use different paths for the 2 sites so they would be easily identifiable. so you have : gs-domain1.web.app/path1 and gs-domain1.web.app/path2

    You will find the add another site function at the bottom of the hosting section below 1